I will try in short words write about using assetic in Symfony2 project.
Why do I need assetic anyway? What is that?
That was the first question I asked myself before asked my good friend ‘Google’.
Let assetic bundle do that for us:
For this article, I choose one option for using assetic, so let’s start:
First of all, download yui compressor from the Yahoo! Site and unpack ‘.jar’ file inside ‘app/Resources/java’ folder inside your project.
Rename it to ‘yuicompressor.jar’.
This tells to assetic that each file inside ..public/css folder need to be handled with assetic. You don’t have to specify each file manually. Filter attribute is name of compressor (filter) that we are using. In this case, we are using yui_css compressor. Next we need to make some changes in main config.yml file to make use of our assetic configuration:
assetic: debug: %kernel.debug% use_controller: false filters: yui_css: jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar" yui_js: jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar"
And that is all for basic configuration, We can start using assetic inside project. Don’t forget to delete existing cache and use command line tool to dump assetic:
php app/console assetic:dump
php app/console cache:clear php app/console assetic:dump
Enjoy with Symfony2.0 like me every day! 🙂