1 - Download and add yuicompressor to your project
Unzip, go to build/ dir and extract yuicompressor-2.4.7.jar to put it in your app/Resources/java/ project dir. (In addition, you can rename yui file for yuicompressor.jar)
2 - Enable yui compression for prod environement
This is logical to add yui compressor in your config_prod.yml file and not for all environment (you should remove lines from config.yml).
So add theses lines in config_prod.yml:
assetic:
debug: false
filters:
yui_js:
jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar"
apply_to: "\.js"
yui_css:
jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar"
apply_to: "\.css"
3 - Verify you prod controller file
Go to web/app.php, and set prod / false (false for no debug).
$kernel = new AppKernel('prod', false);
4 - Clear cache
If you want to rebuild your CSS and JS (after update), never forget to clear cache in prod otherwise modifications will be ignored by yui compressor:
php app/console cache:clear --env=prod --no-debug
5 - Regenerate fixtures with compression
Finally, you can generate and compress your files !
php app/console assetic:dump --env=prod --no-debug -v
Note that -v show more details about the process of compression, you will be able to see if there is an error taht causes problems with yui compressor !
For example, the JS comment tag "/!" causes trouble with yui compressor, you should rename all "/!" for "/*" in your JS files.
That's it ^^