Symfony2 uses Assetic for asset management, I have previously written about its use for JavaScript and CSS files. In this post I am going to look at another of its uses, optimising images. Amongst its many filters, Assetic currently has four which can be used for on-the-fly image optimisation. This way you can get the [...]
Archive for May, 2011
Symfony2: Make your own Assetic Filter
Symfony2 uses Assetic as its asset manager, it provides many excellent filters for processing CSS, JavaScript and Image files. You may find though that the existing filters do not perform a task you need. Thanks to the excellent Dependency Injection in Symfony2 it is easy to write your own filter and put it to use [...]
When Dependency Injection goes Wrong
Introduction Dependency Injection (DI) is finally starting to take off in a big way in PHP. Whilst there have been projects such as Phemto for a while now it has taken it being made a fundamental part of, the now in beta, Symfony2 to really make its mark. Whilst you can still avoid it when [...]
Symfony2: Using CoffeeScript with Assetic
CoffeeScript is a scripting language which is compiled to run as JavaScript. It let you write simpler code with improvements in much of the JavaScript syntax, mainly inspired by Ruby and Python. It is served up to the end user as JavaScript so it requires nothing on the end users part. If you are using [...]
Symfony2: Using Assetic from Twig
After my earlier post digging in to how Assetic (Symfony2‘s asset manager) works, I am now going to look at how you should actually use it from Symfony2′s templating engine Twig. Kris Wallsmith the developer of Assetic pointed me in the right direction in the comments on that post. He has now added some official [...]
Symfony2: Injecting Dependencies Step by Step
In this post I will go through removing directly created dependencies from a Symfony2 controller and instead injecting them using The Dependency Injection Container (DIC). At the end of my last post I had an Asset Controller which looked like this: <?php namespace LimeThinking\SpringBundle\Controller; use Assetic\AssetManager; use Assetic\Cache\FilesystemCache; use Assetic\Factory\AssetFactory; use Assetic\Factory\LazyAssetManager; use [...]
Symfony2: Using Assetic for CSS and JavaScript Management
Edit: Please read the first the first comment from Kris Wallsmith, this explains that you do not need to write any PHP at all to make use of Assetic, it can be configured directly from Twig templates. My follow up post Symfony2: Using Assetic from Twig has more on this. Nevertheless the following should give [...]
Symfony2: Base Class for Common Dependencies
I have previously written about the different ways of injecting dependencies in Symfony2. In this post I will look at managing common dependencies in order to reduce code and config repetition. I will look at it using the same controller as before but this can be used for any service and not only controllers. Simply [...]
Symfony2: Dependency Injection Types – Update
In my previous post I discussed the various ways of injecting dependencies in Symfony2. Symfony2 is not yet in a stable condition and has only just reached the first beta release. As such changes are still being made on regular basis. Some of these changes are to the Dependency Injection Container and some of the [...]


