Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 Assetic Route and Resource Errors

I have template for example index.html.php where I use php assetic loader like this

<?php foreach ($view['assetic']->javascripts(
    array('@AcmeFooBundle/Resources/public/js/*')) as $url): ?>
<script type="text/javascript" src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach; ?>

If I do any changes for my template file I get Route "_assetic_2b431f4" does not exist.

If I change

assetic:
    use_controller: false

I get Cannot load resource ".". Error.

This comes when I do even one line change to file, so something about the cache. Clearing cache don't help etc. Any Ideas?

like image 1000
user257980 Avatar asked Oct 22 '11 16:10

user257980


1 Answers

You have to go into routing_dev.yml and remove these lines:

_assetic:
    resource: .
    type:     assetic

Then everything should work.

This answer was also given here:

How to make Symfony2 to load CSS, JS files directly and not via PHP?

EDIT: And if you haven't done so already, make sure you've done the whole

php app/console assetic:dump

thing that's given in the documentation:

http://symfony.com/doc/current/cookbook/assetic/asset_management.html#dumping-asset-files

like image 188
kdazzle Avatar answered Oct 04 '22 03:10

kdazzle