Asset Management for PHP

Overview

Assetic Build Status

Assetic is an asset management framework for PHP.

Project status

This project is not maintained anymore. Development has been taken over at https://github.com/assetic-php/assetic under the package name assetic/framework.

Example

<?php

use Assetic\Asset\AssetCollection;
use Assetic\Asset\FileAsset;
use Assetic\Asset\GlobAsset;

$js = new AssetCollection(array(
    new GlobAsset('/path/to/js/*'),
    new FileAsset('/path/to/another.js'),
));

// the code is merged when the asset is dumped
echo $js->dump();

Assets

An Assetic asset is something with filterable content that can be loaded and dumped. An asset also includes metadata, some of which can be manipulated and some of which is immutable.

Property Accessor Mutator
content getContent setContent
mtime getLastModified n/a
source root getSourceRoot n/a
source path getSourcePath n/a
target path getTargetPath setTargetPath

The "target path" property denotes where an asset (or an collection of assets) should be dumped.

Filters

Filters can be applied to manipulate assets.

<?php

use Assetic\Asset\AssetCollection;
use Assetic\Asset\FileAsset;
use Assetic\Asset\GlobAsset;
use Assetic\Filter\LessFilter;
use Assetic\Filter\Yui;

$css = new AssetCollection(array(
    new FileAsset('/path/to/src/styles.less', array(new LessFilter())),
    new GlobAsset('/path/to/css/*'),
), array(
    new Yui\CssCompressorFilter('/path/to/yuicompressor.jar'),
));

// this will echo CSS compiled by LESS and compressed by YUI
echo $css->dump();

The filters applied to the collection will cascade to each asset leaf if you iterate over it.

<?php

foreach ($css as $leaf) {
    // each leaf is compressed by YUI
    echo $leaf->dump();
}

The core provides the following filters in the Assetic\Filter namespace:

  • AutoprefixerFilter: Parse and update vendor-specific properties using autoprefixer
  • CoffeeScriptFilter: compiles CoffeeScript into Javascript
  • CompassFilter: Compass CSS authoring framework
  • CssEmbedFilter: embeds image data in your stylesheets
  • CssImportFilter: inlines imported stylesheets
  • CssMinFilter: minifies CSS
  • CleanCssFilter: minifies CSS
  • CssRewriteFilter: fixes relative URLs in CSS assets when moving to a new URL
  • DartFilter: compiles Javascript using dart2js
  • EmberPrecompileFilter: precompiles Handlebars templates into Javascript for use in the Ember.js framework
  • GoogleClosure\CompilerApiFilter: compiles Javascript using the Google Closure Compiler API
  • GoogleClosure\CompilerJarFilter: compiles Javascript using the Google Closure Compiler JAR
  • GssFilter: compliles CSS using the Google Closure Stylesheets Compiler
  • HandlebarsFilter: compiles Handlebars templates into Javascript
  • JpegoptimFilter: optimize your JPEGs
  • JpegtranFilter: optimize your JPEGs
  • JSMinFilter: minifies Javascript
  • JSMinPlusFilter: minifies Javascript
  • JSqueezeFilter: compresses Javascript
  • LessFilter: parses LESS into CSS (using less.js with node.js)
  • LessphpFilter: parses LESS into CSS (using lessphp)
  • OptiPngFilter: optimize your PNGs
  • PackagerFilter: parses Javascript for packager tags
  • PackerFilter: compresses Javascript using Dean Edwards's Packer
  • PhpCssEmbedFilter: embeds image data in your stylesheet
  • PngoutFilter: optimize your PNGs
  • ReactJsxFilter: compiles React JSX into JavaScript
  • Sass\SassFilter: parses SASS into CSS
  • Sass\ScssFilter: parses SCSS into CSS
  • SassphpFilter: parses Sass into CSS using the sassphp bindings for Libsass
  • ScssphpFilter: parses SCSS using scssphp
  • SeparatorFilter: inserts a separator between assets to prevent merge failures
  • SprocketsFilter: Sprockets Javascript dependency management
  • StylusFilter: parses STYL into CSS
  • TypeScriptFilter: parses TypeScript into Javascript
  • UglifyCssFilter: minifies CSS
  • UglifyJs2Filter: minifies Javascript
  • UglifyJsFilter: minifies Javascript
  • Yui\CssCompressorFilter: compresses CSS using the YUI compressor
  • Yui\JsCompressorFilter: compresses Javascript using the YUI compressor

Asset Manager

An asset manager is provided for organizing assets.

<?php

use Assetic\AssetManager;
use Assetic\Asset\FileAsset;
use Assetic\Asset\GlobAsset;

$am = new AssetManager();
$am->set('jquery', new FileAsset('/path/to/jquery.js'));
$am->set('base_css', new GlobAsset('/path/to/css/*'));

The asset manager can also be used to reference assets to avoid duplication.

<?php

use Assetic\Asset\AssetCollection;
use Assetic\Asset\AssetReference;
use Assetic\Asset\FileAsset;

$am->set('my_plugin', new AssetCollection(array(
    new AssetReference($am, 'jquery'),
    new FileAsset('/path/to/jquery.plugin.js'),
)));

Filter Manager

A filter manager is also provided for organizing filters.

<?php

use Assetic\FilterManager;
use Assetic\Filter\Sass\SassFilter;
use Assetic\Filter\Yui;

$fm = new FilterManager();
$fm->set('sass', new SassFilter('/path/to/parser/sass'));
$fm->set('yui_css', new Yui\CssCompressorFilter('/path/to/yuicompressor.jar'));

Asset Factory

If you'd rather not create all these objects by hand, you can use the asset factory, which will do most of the work for you.

<?php

use Assetic\Factory\AssetFactory;

$factory = new AssetFactory('/path/to/asset/directory/');
$factory->setAssetManager($am);
$factory->setFilterManager($fm);
$factory->setDebug(true);

$css = $factory->createAsset(array(
    '@reset',         // load the asset manager's "reset" asset
    'css/src/*.scss', // load every scss files from "/path/to/asset/directory/css/src/"
), array(
    'scss',           // filter through the filter manager's "scss" filter
    '?yui_css',       // don't use this filter in debug mode
));

echo $css->dump();

The AssetFactory is constructed with a root directory which is used as the base directory for relative asset paths.

Prefixing a filter name with a question mark, as yui_css is here, will cause that filter to be omitted when the factory is in debug mode.

You can also register Workers on the factory and all assets created by it will be passed to the worker's process() method before being returned. See Cache Busting below for an example.

Dumping Assets to static files

You can dump all the assets an AssetManager holds to files in a directory. This will probably be below your webserver's document root so the files can be served statically.

<?php

use Assetic\AssetWriter;

$writer = new AssetWriter('/path/to/web');
$writer->writeManagerAssets($am);

This will make use of the assets' target path.

Cache Busting

If you serve your assets from static files as just described, you can use the CacheBustingWorker to rewrite the target paths for assets. It will insert an identifier before the filename extension that is unique for a particular version of the asset.

This identifier is based on the modification time of the asset and will also take depended-on assets into consideration if the applied filters support it.

<?php

use Assetic\Factory\AssetFactory;
use Assetic\Factory\Worker\CacheBustingWorker;

$factory = new AssetFactory('/path/to/asset/directory/');
$factory->setAssetManager($am);
$factory->setFilterManager($fm);
$factory->setDebug(true);
$factory->addWorker(new CacheBustingWorker());

$css = $factory->createAsset(array(
    '@reset',         // load the asset manager's "reset" asset
    'css/src/*.scss', // load every scss files from "/path/to/asset/directory/css/src/"
), array(
    'scss',           // filter through the filter manager's "scss" filter
    '?yui_css',       // don't use this filter in debug mode
));

echo $css->dump();

Internal caching

A simple caching mechanism is provided to avoid unnecessary work.

<?php

use Assetic\Asset\AssetCache;
use Assetic\Asset\FileAsset;
use Assetic\Cache\FilesystemCache;
use Assetic\Filter\Yui;

$yui = new Yui\JsCompressorFilter('/path/to/yuicompressor.jar');
$js = new AssetCache(
    new FileAsset('/path/to/some.js', array($yui)),
    new FilesystemCache('/path/to/cache')
);

// the YUI compressor will only run on the first call
$js->dump();
$js->dump();
$js->dump();

Twig

To use the Assetic Twig extension you must register it to your Twig environment:

<?php

$twig->addExtension(new AsseticExtension($factory));

Once in place, the extension exposes a stylesheets and a javascripts tag with a syntax similar to what the asset factory uses:

{% stylesheets '/path/to/sass/main.sass' filter='sass,?yui_css' output='css/all.css' %}
    <link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}

This example will render one link element on the page that includes a URL where the filtered asset can be found.

When the extension is in debug mode, this same tag will render multiple link elements, one for each asset referenced by the css/src/*.sass glob. The specified filters will still be applied, unless they are marked as optional using the ? prefix.

This behavior can also be triggered by setting a debug attribute on the tag:

{% stylesheets 'css/*' debug=true %} ... {% stylesheets %}

These assets need to be written to the web directory so these URLs don't return 404 errors.

<?php

use Assetic\AssetWriter;
use Assetic\Extension\Twig\TwigFormulaLoader;
use Assetic\Extension\Twig\TwigResource;
use Assetic\Factory\LazyAssetManager;

$am = new LazyAssetManager($factory);

// enable loading assets from twig templates
$am->setLoader('twig', new TwigFormulaLoader($twig));

// loop through all your templates
foreach ($templates as $template) {
    $resource = new TwigResource($twigLoader, $template);
    $am->addResource($resource, 'twig');
}

$writer = new AssetWriter('/path/to/web');
$writer->writeManagerAssets($am);

Assetic is based on the Python webassets library (available on GitHub).

Comments
  • Assetic is not aware of asset dependencies

    Assetic is not aware of asset dependencies

    As discussed here there is a problem with the new implementation of the compass binary. The problem is that, the cache system, checks the timestamp of the sass file without involving the filter. So if you have a main file which imports other "subfiles" (a typical situation working with compass) and you never edit this main file you never get a recompile.

    The process of check the timestamp of an assetic file should in some way involve the filter to get a complete list of files to check and eventually trigger the recompile by checking all the timestamps.

    This issue is related to compass, but I think it should also appear in Sass and ScssFilter and also on any filter that deal with an asset with a tree of subassets

    enhancement 
    opened by matteosister 109
  • problem running filters relying on vendor programs located in paths containing spaces on Windows

    problem running filters relying on vendor programs located in paths containing spaces on Windows

    For example, when Assetic tries to run Java on Windows (which is installed in C:\Program Files\Java\...) I'm getting the error that command "C:\Program" could not be found.

    opened by craue 48
  • Cannot use all Compass functionalities

    Cannot use all Compass functionalities

    We don't directly use compass binary, so we cannot use compass options like images_dir in the CompassFilter. So, some functionalities like sprite cannot be used. A workaround will be to create a configuration file 'config.rb' with compass options in the same temp directory used for the temp sass/scss file. But it's an ugly way... Or we can stop use sass --compass, and modify compass to be able to use add a load path (I've open a discussion on compass google groups)

    defect 
    opened by MoOx 41
  • [WIP] asset dependencies

    [WIP] asset dependencies

    This is basically what I'm thinking for making Assetic aware of asset dependencies. Each filter can optionally implement getChildren($asset, $factory) and return an array of assets that the supplied asset depends on.

    The LazyAssetManager has the factory, so I've added a getLastModified($asset) method there, which considers the mtime of each dependency as well as the root asset.

    opened by kriswallsmith 30
  • SassFilter - Empty CSS files generated

    SassFilter - Empty CSS files generated

    I am using the SASS filter and after issuing

    php app/console assetic:dump 
    

    the dumped CSS files are all empty.

    config.yml

    assetic:
        debug:          '%kernel.debug%'
        use_controller: false
        read_from: '%kernel.root_dir%/../web'
        write_to: '%kernel.root_dir%/../web'
        ruby: '%ruby%'
        java: '%java%'
        filters:
            sass:
              bin: '%sass%'
              apply_to: '\.scss$'
              load_paths:
                - '%kernel.root_dir%/../web/assets'
            cssrewrite: ~
            yui_css:
                jar: '%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar'
            yui_js:
                jar: '%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar'
    

    config_dev.yml

    assetic:
        use_controller: true
    

    base.html.haml

    - stylesheets combine=true filter='cssrewrite,?yui_css' output='assets/css/base.css' |
                'assets/bundles/ictsamticoreassets/css/base/base.scss' |
                %link(href=asset_url type="text/css" rel="stylesheet")
    
    - stylesheets combine=true filter='cssrewrite,?yui_css' output='assets/css/frontend.css' |
            'assets/bundles/ictsamticoreassets/css/frontend/main.scss' |
            %link(href=asset_url type="text/css" rel="stylesheet")
    

    The first stylesheet (base.css) seems to compile fine, however the other (frontend.css) is empty.

    I am running on a Windows 7 SP1 64-bit machine with PHP version 5.4.19, Ruby 2.0.0 (64 bit) and sass v3.2.10.

    I suspect it has something to do with reading the output of the compile command from the file pipe (in proc_open), which for some reason is empty. Running the SASS compilation commands outputs the CSS code I expect, so that shouldn't be the problem.

    I also stumbled upon this issue (https://github.com/kriswallsmith/assetic/issues/99), and tried setting the $env parameter to null, but to no avail.

    The compilation with Assetic runs fine in another Debian machine.

    Probably this is a PHP bug (https://bugs.php.net/bug.php?id=50503, referenced in the issue above), but I'd love to know whether there is another way to fix this. I have been struggling with this (ridiculous) issue for 2 days and it's keeping me from doing the real work, so it would be fantastic if a fix were to be found.

    Thanks.

    opened by gentisaliu 28
  • Cssrewrite filter breaking image paths

    Cssrewrite filter breaking image paths

    I'm trying to use the cssrewrite filter (also followed #53 and I'm set up the proper way, at least according to that thread and everything else I've read).

    As soon as I do an app/console assetic:dump, I get an exception thrown because images (defined in the css) cannot be found. However, as mentioned above, I'm using the exact same setup outlined elsewhere.

    The error:

    $ app/console assetic:dump
    Dumping all dev assets.
    Debug mode is on.
    
    23:29:26 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/7673c91.css
    
    [Assetic\Exception\FilterException]
    An error occurred while running:
    '/usr/bin/java' '-jar' '/Users/mbadolato/Sites/fbusa/app/Resources/java/cssembed-0.4.5.jar' '--charset' 'UTF-8' '--root' '/Users/mbadolato/Sites/fbusa/app/../web/bundles/fbsite/css' '/private/var/folders/w6/jh3gd9b567551qm01tqnlvh80000gn/T/assetic_cssembedk0VRgP'
    
    Error Output:
    [ERROR] /Users/mbadolato/Sites/fbusa/app/../web/bundles/fbsite/css/../../bundles/fbsite/img/sticker_sidebar_yellow.png (No such file or directory)
    

    Now, looking at that path and error message (No such file), that's absolutely true:

    $ ls /Users/mbadolato/Sites/fbusa/app/../web/bundles/fbsite/css/../../bundles/fbsite/img/sticker_sidebar_yellow.png
    ls: /Users/mbadolato/Sites/fbusa/app/../web/bundles/fbsite/css/../../bundles/fbsite/img/sticker_sidebar_yellow.png: No such file or directory
    

    But, add an additional '../' to the path (/../../../ instead of /../../), and the file is found:

    $ ls /Users/mbadolato/Sites/fbusa/app/../web/bundles/fbsite/css/../../../bundles/fbsite/img/sticker_sidebar_yellow.png
    -rw-r--r--  1 mbadolato  mbadolato    51K Oct 11 23:10 /Users/mbadolato/Sites/fbusa/app/../web/bundles/fbsite/css/../../../bundles/fbsite/img/sticker_sidebar_yellow.png
    

    It appears that the paths Assetic is trying to use during generation is incorrect

    The Twig template block:

    {% stylesheets filter='cssrewrite'
        'bundles/fbsite/css/bootstrap.css'
        'bundles/fbsite/css/custom.css'
        'bundles/fbsite/css/styler.css'
        'bundles/fbsite/css/isotope.css'
        'bundles/fbsite/css/color_scheme.css'
    %}
    <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}
    

    The CSS containing the image it's looking for (granted it will probably fail with all images; this is just where the exception is first thrown):

    $ grep -r sticker_sidebar_yellow src/FB/Bundle/SiteBundle/Resources/public/css/*
    src/FB/Bundle/SiteBundle/Resources/public/css/custom.css:        background: url("../img/sticker_sidebar_yellow.png") no-repeat scroll 0 0 transparent;
    src/FB/Bundle/SiteBundle/Resources/public/css/custom.css:        background: url("../img/sticker_sidebar_yellow.png") no-repeat scroll 0 0 transparent;
    

    Both file shown here with my full path listed, just to show they exist and are correctly relative to each other:

    [bado.local mbadolato ~/Sites/fbusa/src/FB/Bundle/SiteBundle/Resources/public]$ ls css/custom.css -rw-r--r--  1 mbadolato  mbadolato    68K Oct 11 22:01 css/custom.css
    [bado.local mbadolato ~/Sites/fbusa/src/FB/Bundle/SiteBundle/Resources/public]$ ls img/sticker_sidebar_yellow.png
    -rw-r--r--@ 1 mbadolato  mbadolato    51K Oct 11 21:10 img/sticker_sidebar_yellow.png
    

    And in the web\bundles\fbsite directory:

    [bado.local mbadolato ~/Sites/fbusa/web/bundles/fbsite]$ ls css/custom.css
    -rw-r--r--  1 mbadolato  mbadolato    68K Oct 11 23:24 css/custom.css
    [bado.local mbadolato ~/Sites/fbusa/web/bundles/fbsite]$ ls img/sticker_sidebar_yellow.png
    -rw-r--r--  1 mbadolato  mbadolato    51K Oct 11 23:24 img/sticker_sidebar_yellow.png
    

    This is Symfony 2.4.0 beta (also tried reverting back to Symfony 2.3 in case there were conflicts).

        "require": {
            "php": ">=5.5",
            "symfony/symfony": "~2.4",
            "doctrine/orm": "~2.4",
            "doctrine/doctrine-bundle": "~1.2",
            "twig/extensions": "~1.0",
            "symfony/assetic-bundle": "~2.3",
            "symfony/swiftmailer-bundle": "~2.3",
            "symfony/monolog-bundle": "~2.4",
            "sensio/distribution-bundle": "~2.3",
            "sensio/framework-extra-bundle": "~2.3",
            "sensio/generator-bundle": "~2.3",
            "incenteev/composer-parameter-handler": "~2.0",
            "twbs/bootstrap": "~2"
        },
    

    Any thoughts? Do I have something incorrectly set up? Is there any other information I can provide to help debug this?

    Update Removing the cssrewrite filter allows assetic::dump to finish, however images are broken (obviously) since the paths haven't been corrected.

    [bado.local mbadolato ~/Sites/fbusa]$ app/console assetic:dump
    Dumping all dev assets.
    Debug mode is on.
    
    23:58:44 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/36d223d.css
    23:58:48 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/36d223d_bootstrap_1.css
    23:58:50 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/36d223d_custom_2.css
    23:58:51 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/36d223d_styler_3.css
    23:58:52 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/36d223d_isotope_4.css
    23:58:52 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/36d223d_color_scheme_5.css
    23:58:53 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/5747f6e.css
    23:58:53 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/5747f6e_jquery.fancybox_1.css
    23:58:54 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/6aaec54.css
    23:58:55 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/6aaec54_IE-fix_1.css
    23:58:55 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/a0602ba.css
    23:58:58 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/a0602ba_font-awesome_1.css
    23:58:59 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/a0602ba_font-awesome-ie7_2.css
    23:59:00 [file+] /Users/mbadolato/Sites/fbusa/app/../web/css/a0602ba_flexslider_3.css
    23:59:00 [file+] /Users/mbadolato/Sites/fbusa/app/../web/js/javascript.js
    23:59:00 [file+] /Users/mbadolato/Sites/fbusa/app/../web/js/javascript_bootstrap_1.js
    23:59:00 [file+] /Users/mbadolato/Sites/fbusa/app/../web/js/javascript_style-switcher_2.js
    23:59:00 [file+] /Users/mbadolato/Sites/fbusa/app/../web/js/javascript_jquery-ui.min_3.js
    23:59:00 [file+] /Users/mbadolato/Sites/fbusa/app/../web/js/javascript_jquery.isotope_4.js
    23:59:00 [file+] /Users/mbadolato/Sites/fbusa/app/../web/js/5bd3dac.js
    23:59:00 [file+] /Users/mbadolato/Sites/fbusa/app/../web/js/5bd3dac_jquery.fancybox.pack_1.js
    23:59:00 [file+] /Users/mbadolato/Sites/fbusa/app/../web/js/5bb39b3.js
    23:59:00 [file+] /Users/mbadolato/Sites/fbusa/app/../web/js/5bb39b3_custom_1.js
    [bado.local mbadolato ~/Sites/fbusa]$
    
    opened by mbadolato 23
  • Need Symfony?

    Need Symfony?

    Need Symfony framework to run? I recive this error Fatal error: Class 'Symfony\Component\Process\ProcessBuilder' not found in src/Assetic/Filter/Yui/BaseCompressorFilter.php on line 63

    opened by vahid-sohrabloo 21
  • Symfony 2 - Assetic Javascript compression causing errors

    Symfony 2 - Assetic Javascript compression causing errors

    I get the same trouble mentionned here: http://stackoverflow.com/questions/9480707/symfony-2-assetic-javascript-compression-causing-errors Unable to run my site in production mode.

    opened by topclaudy 20
  • CompassFilter broken

    CompassFilter broken

    Hey, The new CompassFilter seems to be throwing around all sorts of errors on Win7. The compass version may be the culprit too but I doubt it. Can anyone tell me if this has been tested and on which compass version? Thanks

    opened by schniper 20
  • yui_js filter hang on windows

    yui_js filter hang on windows

    Hello, on Windows 7 when using assetic:dump, or when using dev envrionment java process hangs indefinetly. So it hangs when compressing javascript but works with .css just fine.

    Works: running it from the command-line java -jar yuicompressor.jar jquery.js -o min.js"

    Does not work: Everything else.

    Tried master branch, proc-escaping branch, 1.0.1 version

    The temp file that yui compressor writes to contains the resulting javascript, but the process does not quit after completing the job. command args look like so: C:\Windows\system32\java.EXE "-jar" "C:\path to yui jar" "--type" "js" "--charset" "UTF-8" "C:\path to temp file"

    defect 1.0 
    opened by biGGer 19
  • LazyAssetManager::getLastModified broken for AssetCollections

    LazyAssetManager::getLastModified broken for AssetCollections

    We've been trying to get the new "deep mtime" feature running for a simple SCSS file that @imports another file. I've got the impression that there's still a subtle bug, although I still don't understand 100% why it happens or how to fix it.

    I get into LazyAssetManager::getLastModified() with an $asset that is an AssetCollection as follows.

    $asset: an AssetCollection
        filters: [ ScssFilter, CssRewriteFilter ]
        assets: [ $fileAsset ]
    $fileAsset: a FileAsset (SCSS file) 
    

    (hope you get the idea)

    Now around line 228, LazyAssetManager clones this Collection, clears the filter, adds (in the first iteration) the ScssFilter again and calls $clone->load() (line 233).

    This brings us to AssetCollection::load, which (around line 131 there) loops

    foreach ($this as $asset) ...
    

    At that moment the AssetCollectionIterator kicks in (in AssetCollection::getIterator) and somehow (must be related to the "clones" passed, don't get it) we end up with an $asset that contains the original two filters (Scss and CssRewrite).

    This asset's getContent() does not anymore contain the original @import statements so the filter's getChildren() method (called in LazyAssetManager line 241) cannot find the "deep" assets anymore.

    I was inclined to fix this with a special treatment for AssetCollections in the LazyAssetManager, however, that's probably wrong as the AssetCollection should handle it internally for this use case.

    _Additional question 1_

    A variation of this case where I am unsure how things would behave is if the $fileAsset from above would in turn hold a filter. If so, where would the "extraction" (incrementally applying all filters to the raw asset, scanning each intermediate result) happen for this $fileAsset?

    _Additional question 2_

    As I get it, LazyAssetManager::getLastModified() incrementally applies all filters to a given asset and uses the "next last" filter to extract the "deep" assets (as new Assets).

    Because that happens (in each iteration) on a clone, I am wondering if the filters at the beginning of the chain are executed repeatedly?

    _Additional question 3_

    Also, getLastModified() needs to be called to determine if the compiled/processed set of assets is still fresh. It would obviously be pointless to (partially) process the assets to look at the intermediate result to determine the "deep" dependencies in every request. So how does the information about the deep dependencies get cached?

    opened by mpdude 17
  • PHP Fatal error:  Interface 'Assetic\Factory\Worker\WorkerInterface' not found.

    PHP Fatal error: Interface 'Assetic\Factory\Worker\WorkerInterface' not found.

    Hey,

    Good day.

    Seems kriswallsmith assetic has been replaced by assetic-php. I have a custom LastModifiedStrategy which worked fine but now throws the error:

    PHP Fatal error:  Interface 'Assetic\Factory\Worker\WorkerInterface' not found...
    

    If I replace the Assetic\Factory\Worker\WorkerInterface with Assetic\Contracts\Factory\Worker\WorkerInterface instead, the new error is:

    Argument 1 passed to AsseticBundle\Service::setCacheBusterStrategy() must be an instance of Assetic\Factory\Worker\WorkerInterface
    

    Been trying to revert my composer file to a previous version, but can't seem to get kriswallsmith version installed again.

    Any assistance would be much appreciated, thanks.

    Regards. Jarrett

    opened by jarrettj 1
  • CssRewriteFilter on windows environment

    CssRewriteFilter on windows environment

    Hi! I'm working on azure with a windows server running PHP, I dont know if this is a bug but I have problems when rewritting the urls inside my css. This is an example of a route: D:\home\site\wwwroot\public_html\templates\home\css\minified_products_1.css , I changed the slashes of the CssRewriteFilter.php for DIRECTORY_SEPARATOR and its works, maybe the filter doesnt support windows environment?

    Thanks!

    opened by diego-sorribas 0
  • Composer 'leafo/scssphp' repo archived

    Composer 'leafo/scssphp' repo archived

    Wondering if there are any plans replacing?

    leafo/scssphp

    with

    scssphp/scssphp

    and updating its references in src/Assetic/Filter/ScssphpFilter.php?

    Greetings

    opened by jimstrike 3
  • Attempted to load class

    Attempted to load class "Compiler" from namespace "Leafo\ScssPhp".

    Hi there,

    I am using the package: "scssphp/scssphp": "^1.0.6"

    When I delete vendor, var/cache and clear cache of composer, I run: composer install

    then this message outputs:

    Attempted to load class "Compiler" from namespace "Leafo\ScssPhp".           
      Did you forget a "use" statement for e.g. "Twig_Compiler", "Twig\Compiler",  
       "Symfony\Component\ExpressionLanguage\Compiler", "Symfony\Component\Depend  
      encyInjection\Compiler\Compiler" or "ScssPhp\ScssPhp\Compiler"? 
    

    Then, I run the following command:

    fgrep -R "use Leafo" vendor/
    

    and I discovered that your package still uses Leafo/scss (this package was abandoned in favour of scssphp/scssphp):

    vendor/kriswallsmith/assetic/src/Assetic/Filter/ScssphpFilter.php:use Leafo\ScssPhp\Compiler;
    
    Operating System: Ubuntu 18.04.3 LTS 
                Kernel: Linux 5.3.0-26-generic
    
    PHP 7.2.24-0ubuntu0.18.04.2 (cli) (built: Jan 13 2020 18:39:59) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.24-0ubuntu0.18.04.2, Copyright (c) 1999-2018, by Zend Technologies
    

    What's wrong?

    Best regards.

    opened by abelardolg 19
  • truncated output with stylus

    truncated output with stylus

    stylus compile fine the files but $process->getOutput(); does not return the entire output , could you help me please, ubuntu DISTRIB_RELEASE=18.04 DISTRIB_CODENAME=bionic using php 7.0.33 ,
    kriswallsmith/assetic v1.2.1 , symfony/process v2.8.50

    opened by omni-anuncios 2
Releases(v1.4.0)
  • v1.4.0(Nov 11, 2016)

  • v1.3.2(Nov 17, 2015)

    • Added support for symfony/process 3
    • Fixed the compatibility with Twig 2 due to a new deprecation
    • Fixed the support of legacy scssphp formatter class names, which have been removed from scssphp 0.5
    Source code(tar.gz)
    Source code(zip)
  • v1.3.1(Nov 17, 2015)

  • v1.3.0(Aug 31, 2015)

    Features

    • Added sourcemap (sass >= 3.3) support to SassFilter
    • Added support for import options in less
    • Allow to pass the precision for float numbers in the Sass filter
    • Make JSqueeze filter work with 1.x and 2.x
    • Added React JSX filter
    • Added SeparatorFilter
    • Make the Twig integration compatible with Twig 2.0

    Bug fixes

    • Do not add empty load path as import path in the ScssphpFilter
    Source code(tar.gz)
    Source code(zip)
Owner
Kris Wallsmith
Kris Wallsmith
Phraseanet 4.1 - Digital Asset Management application

Phraseanet 4.1 - Digital Asset Management application Main Features : Several GUI : Prod, Admin, Thesaurus, Lightbox ,Report, Metadata Management (inc

Alchemy 201 Jan 6, 2023
Munee: Standalone PHP 5.3 Asset Optimisation & Manipulation

Munee: Standalone PHP 5.3 Asset Optimisation & Manipulation #####On-The-Fly Image Resizing, On-the-fly LESS, SCSS, CoffeeScript Compiling, CSS & JavaS

Cody Lundquist 837 Dec 21, 2022
The Asset component manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files.

Asset Component The Asset component manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files. Res

Symfony 2.9k Jan 5, 2023
An asset compression plugin for CakePHP. Provides file concatenation and a flexible filter system for preprocessing and minification.

Asset Compress Asset Compress is CakePHP plugin for helping reduce the number of requests, and optimizing the remaining requests your application make

Mark Story 367 Jul 20, 2022
Doki Doki Literature Club Plus Asset Decrypter

DDLC Plus Asset Decrypter Doki Doki Literature Club Plus Asset Decrypter Used to decrypt encrypted Streaming Asset Bundle files (*.cy) in DDLC-Plus. H

Jim Wu 16 Nov 16, 2022
NotrinosERP is an open source, web-based enterprise management system that written in PHP and MySql.

NotrinosERP is an open source, web-based enterprise management system that written in PHP and MySql. NotrinosERP contains all the required modules for running any small to medium size businesses. It supports multi users, multi currencies, multi languages

Phương 56 Dec 20, 2022
Javascript Minifier built in PHP

JShrink JShrink is a php class that minifies javascript so that it can be delivered to the client quicker. This code can be used by any product lookin

Tedious Developments 678 Dec 31, 2022
A PHP implementation of bower :bird:

Bowerphp An implementation of bower in PHP. https://bowerphp.github.io/ Installation $ composer require beelab/bowerphp Configuration Currently, you c

BeeLab 473 Dec 30, 2022
PHP class to generate bookmarklets from Javascript code

Bookmarklet Gen Convert readable Javascript code into bookmarklet links Features removes comments compresses code by removing extraneous spaces, but n

྅༻ Ǭɀħ ༄༆ཉ 13 Oct 5, 2022
A Parser for CSS Files written in PHP. Allows extraction of CSS files into a data structure, manipulation of said structure and output as (optimized) CSS

PHP CSS Parser A Parser for CSS Files written in PHP. Allows extraction of CSS files into a data structure, manipulation of said structure and output

Raphael Schweikert 1.6k Jan 5, 2023
Commenting program developed with Html & Css & Php JavaScript Languages ​​and MySql

CommentSystem [BETA] Commenting program developed with Html & Css & Php JavaScript Languages and MySql How does it work ? After you set up your Databa

Azad 0 May 19, 2022
GLPI is a Free Asset and IT Management Software package, Data center management, ITIL Service Desk, licenses tracking and software auditing.

GLPI stands for Gestionnaire Libre de Parc Informatique is a Free Asset and IT Management Software package, that provides ITIL Service Desk features, licenses tracking and software auditing.

GLPI 2.9k Jan 2, 2023
Asset Management for PHP

Assetic Assetic is an asset management framework for PHP. Project status This project is not maintained anymore. Development has been taken over at ht

Kris Wallsmith 3.8k Jan 4, 2023
A free open source IT asset/license management system

Snipe-IT - Open Source Asset Management System This is a FOSS project for asset management in IT Operations. Knowing who has which laptop, when it was

snipe 7.2k Jan 7, 2023
Phraseanet 4.1 - Digital Asset Management application

Phraseanet 4.1 - Digital Asset Management application Main Features : Several GUI : Prod, Admin, Thesaurus, Lightbox ,Report, Metadata Management (inc

Alchemy 201 Jan 6, 2023
Snipe-IT - A free open source IT asset/license management system

Snipe-IT - A free open source IT asset/license management system

snipe 7.2k Jan 4, 2023
IT Asset Management & Tickets Web Application - Laravel 5.2

I.V.D. Assets I.V.D. Assets is a web application developed with Laravel 5.2, that caters to the needs of I.T. Departments and Help Desks. Manage all y

Terry Ferreira 21 Nov 27, 2022
Theme and asset management for laravel

Laravel-Themevel Themevel is a Laravel theme and asset management package. You can easily integrate this package with any Laravel based project. Featu

Shipu Ahamed 339 Dec 23, 2022
Theme and asset management for laravel

Laravel-Themevel Themevel is a Laravel theme and asset management package. You can easily integrate this package with any Laravel based project. Featu

Shipu Ahamed 339 Dec 23, 2022
Munee: Standalone PHP 5.3 Asset Optimisation & Manipulation

Munee: Standalone PHP 5.3 Asset Optimisation & Manipulation #####On-The-Fly Image Resizing, On-the-fly LESS, SCSS, CoffeeScript Compiling, CSS & JavaS

Cody Lundquist 837 Dec 21, 2022