Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

assetic error

edited March 2013 in Apps

Trying to get assetic working. I added {# assetic/css/text.css #} to test, but am getting "PHP Fatal error: Uncaught exception 'ErrorException' with message 'filemtime(): stat failed for css_text.css' in /path/to/apps/assetic/handlers/index.php:33"


  • I haven't touched the Assetic app in a while, and it looks like there were two problems: A change to Elefant's autoloader broke the cascading to the app's own autoloader, and I added a file_exists() check before the line with the error you saw too. Seems to be working well again now, but you'll need to update Elefant (the file lib/Autoloader.php) and the Assetic app (the file handlers/index.php).

    Gonna be a bit slow getting back to your other posts, I'm laid up sick and getting through it with tons of NyQuil and 80's movies, haha... I'm sure I'll be back on my feet in a day or so though :)

  • edited March 2013

    Thanks and no worries! I've been having a blast with elefant and posting whatever I think of whenever I think of it. Please don't feel like you need to answer, although I always appreciate and enjoy what you have to say.

    Hope you feel better soon!

  • Still having trouble. I removed apps/assetic and tried again from github, but again assetic/lib/SplClassLoader.php is empty.

  • Installing from the zip works now, though -- thanks!

  • Hmm, having trouble after uploading. ErrorException: tempnam(): open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): (/path/1:/path/2:/path/3) tempnam ("/tmp", "assetic_yui_compressor")

    It looks like php pre 5.5 doesn't respect virtual host settings in sys_get_temp_dir:

  • Can you move the yuicompressor.jar file somewhere inside your open_basedir restricted folders and see if that helps?

  • No difference. It's line 83 of apps/assetic/lib/Assetic/Filter/Yui/BaseCompressorFilter.php: $input = tempnam(sys_get_temp_dir(), 'assetic_yui_compressor');

    sys_get_temp_dir() returns /tmp, but the virtual user doesn't have permission to write to /tmp

    Could you use something like ini_get('upload_tmp_dir') instead?

  • This comes down to the Assetic library itself I'm afraid. I think once I fix the Assetic app to use UglifyJS and CSSMin instead of YUI Compressor, it might sort that out though.

  • Ah well, I have root, so I added permission to use /tmp. Hopefully it's not a big security risk.

  • I'm having trouble configuring assetic/conf/config.php. If I set web_path = "cache/assetic", then urls like homes/this-property-id aren't styled because they're looking for <link rel="stylesheet" href="cache/assetic/css.css?v=42" /> instead of <link rel="stylesheet" href="/cache/assetic/css.css?v=42" />.

    However, if I set web_path = "/cache/assetic", then admin/assetic gives ErrorException: filemtime(): stat failed for /cache/assetic/css.css.

    The workaround I'm using is to use web_path = "cache/assetic" and add a '/' in lines 119 and 159 of apps/assetic/handlers/index.php, like so: echo '<link rel="stylesheet" href="/' . $web_path . '/' . $name . '.css?v=' . ASSETIC_VER . '" />';

    That seems to fix the error and the path issue, but I still get an error when I try to recompile assets from the admin screen: ErrorException: touch(): Unable to create file layouts/layouts/admin.html because No such file or directory

  • You shouldn't have to adjust the save_path or web_path in most installs. It looks like there were a couple issues with the admin area. I just pushed a fix to github that should take care of it. Sorry about that!

  • No worries. I installed the latest version and both of those things are fixed. I did notice a new issue. I have these lines in default.html:

    <link rel="stylesheet" type="text/css" href="{# assetic/css/mobile.css #}" />
    {% else %}
    {# assetic/css?css[]=css/reset.css&css[]=css/text.css&css[]=css/960.css&css[]=css/style.css&css[]=css/properties.css #}

    When I recompile assets from assetic/admin, cache/assetic/css_mobile.css is updated after a page view, but cache/assetic/css.css is not.

    Still having trouble installing from designer/installer, BTW. Maybe I'm doing something wrong or my permissions are not what the installer expects. I'm copying and pasting e.g. into the 'Link to a zip file or Github repository' field, but I still get empty files after what the installer claims was a successful install.

  • Is there a way to add scripts or css files to assetic that are called via $page->add_style or $page->add_script? e.g., from apps/navigation/handlers/dropmenu.php

    $page->add_style ('/apps/navigation/css/dropmenu.css');
    $page->add_script ('/apps/navigation/js/dropmenu.js');
  • Hmm, I'll have to test to see if there's a reason it's not updating the files properly. It should recompile when it finds an updated file modification time on the layout compared to the compiled CSS. I'll keep you posted on that.

    Unfortunately there's no way to tie $page->add_script() or add_style in with Assetic yet. That's something that's on my radar, but I haven't figured out the right solution yet.

    As for the installer issues, I've added a bunch more error handling but I think what you're running into is Github's rate limiting on their API. They only allow 60 anonymous calls per hour, which means fetching the file list and up to 60 files before it will start failing.

    An alternative is to grab the zip link from Github (to the left of the git clone url) and use that. Shouldn't hit any limits then :)

  • It does update the individual file, just not the chained one. I was also running into issues with chaining over multiple lines.

    I think you're right about github. Guess I need to create an account there.

    Is there anything like a $head->add_script() function?

  • $page->add_script() starts adding to the head first, unless you specify otherwise, but starts outputting in place once the layout template has started rendering (e.g., on {! app/handler !} style includes in the layout.

    Unfortunately, there's no way to add your credentials to the app, so the Github limit is a hard limit for the installer. It's okay for single app installs, but zip installs should work better and are usually faster too since it only has to retrieve a single file.

  • I see why getting the scripts to assetic is tricky...

    I think I was having trouble with zip installs from the installer, too, and had to download them elsewhere, unzip, and move the folder into apps. I'll try the installer again next time I download an app.

  • This is the error I get installing from a zip file in designer/installer: Zip file installation failed: Could not unzip the file.

  • The above is when I paste the github zip link. If I download it separately and then browse to find the downloaded file, I get this:

    ErrorException: preg_split(): No ending delimiter '/' found
    preg_split ("/, ?", "zip")
    286 lib/Validator.php
    284.                 }
    285.                 if ($type === 'filetype') {
    286.                     $extensions = preg_split ('/, ?', trim (strtolower ($validator)));
    287.                     if ($extensions === false) {
    288.                         $extensions = array ($validator);
  • Ah yes, I fixed that typo just a day or so ago. Should be:

    $extensions = preg_split ('/, ?/', trim (strtolower ($validator)));

    Let me know if after fixing that the uploaded zip works any differently than the Github zip link.

Sign In or Register to comment.