Making Symfony 2 Assetic development comfortable

Tower picture Tower · May 25, 2012 · Viewed 7.9k times · Source

I'm looking for ways to make Symfony 2 Assetic 1.0.2 development easier. I use Assetic for dumping/publishing my assets.

Currently I keep running this command in the background:

php app/console assetic:dump --watch

It helps a lot, every change I make to JS or CSS files will automatically get dumped to the public directory where the resources are fetched from by the browser.

However, I have issues with this:

  1. If I add a new CSS/JS file, for some reason it does not get dumped. I need to stop the watch, clear the cache and initiate the watch again.

  2. It is kind of slow, eats 5%-20% CPU time constantly.

Is there an alternative to development with Assetic? I already tried the approach of serving the resources through a controller (use_controller: true for Assetic), but it was even slower (because let's face the fact, PHP is not for serving static data).

Answer

Matt picture Matt · May 25, 2012

For me, this is the fastest way to develop with Assetic I could find. I tried and I tried to find a better workflow to enhance speed of asset generation, but found none.

There is some work in the master branch of Symfony2 on a ResourceWatcher component which could possibly helps on this issue by:

  1. Speeding up the watching process by relying on native resource watcher like inotify
  2. Fixing problem when resources are added/removed so they are dumped correctly.

You can watch progress on the component in this PR.

Hope someone will provide some tricks to speed up development with assetic or a completely different workflow.

Regards,
Matt