This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Assetic: Use CssMin filter

Discuss Symfony 2 bundles here

Assetic: Use CssMin filter

by DevDavid » Tue Apr 03, 2012 8:54 pm

Everywhere on the web are pages how the YUI Compressor could be used on e.g. CSS files. But nowhere is something how the also built-in CssMinFilter could be used?

My current template code looks like that:

Code: Select all
{% stylesheets output="/css/demo.css" debug=false
    <link href="{{ asset_url }}" rel="stylesheet" media="screen" />
{% endstylesheets %}

I want to minify my CSS with Assetic\Filter\CssMinFilter.
Junior Member
Posts: 1
Joined: Tue Apr 03, 2012 8:52 pm

Re: Assetic: Use CssMin filter

by Czechnology » Mon Jul 16, 2012 4:16 pm

...anyone knows how to set this up?

I modified my congig like this:
Code: Select all
    debug:          %kernel.debug%
    use_controller: false
        cssrewrite: ~
        cssmin:     ~

but then I get an error:
Fatal error: Class 'CssMin' not found in C:\Apache2\htdocs\...\vendor\assetic\src\Assetic\Filter\CssMinFilter.php on line 71

How exactly should I set up my config? I couldn't find any docs on this.
Junior Member
Posts: 24
Joined: Sat Feb 26, 2011 4:27 pm
Location: Prague / Vienna

Re: Assetic: Use CssMin filter

by dcobalt » Fri Jul 20, 2012 9:04 pm

Assetic has several filters, but includes no external libraries out of the box. You'll need to get CSSMin and integrate it into your project, much as you probably did with Gaufrette, Imagine, BaseFacebook for FOSFacebookBundle, or other similar ones (even Assetic counts) etc.

In case you don't know what I'm talking about, just do the following:
- get cssmin-v3.0.1.php (the latest version) from the link I posted
- rename it to cssmin.php and put it in vendor/cssmin/src inside your project
- Check out your autoload.php, add the following line in the list of registered namespaces:
Code: Select all
    'CssMin' => __DIR__.'/../vendor/cssmin/src',

This -should- work. I think. I haven't tried it.
Faithful Member
Posts: 283
Joined: Thu Oct 20, 2011 6:06 pm