Symfony2 Assetic Route and Resource Errors
Asked Answered
O

1

11

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?

Oren answered 22/10, 2011 at 16:46 Comment(0)
P
9

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

Painting answered 16/12, 2011 at 21:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.