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:
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.
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).
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:
inotify
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
For slowness, you can run with --no-debug
and --forks=4
. Install Spork dependency through composer, and run app/console assetic:dump --no-debug --forks=4
.
If you have more cores add more forks. If you want to keep core(s) free lower the number. Not sure why it isn’t 4 times faster - doubtless it is not too intelligent about assigning different assetic jobs to different cores - but it’s a start.
Some things I just tried briefly:
time app/console assetic:dump
real 1m53.511s
user 0m52.874s
sys 0m4.989s
time app/console assetic:dump --forks=4
real 1m14.272s
user 1m12.716s
sys 0m5.752s
time app/console assetic:dump --forks=4 --no-debug
real 1m9.569s
user 1m6.948s
sys 0m5.844s
I'm not sure that this will help with --watch
, as --watch
consumes an entire core on it's own, because while (true)
in PHP.
İn developpement use this:
php app/console assets:install web --symlink
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With