Symfony2 Assetic Route and Resource Errors

徘徊边缘 提交于 2019-12-04 17:58:14

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/7861030/symfony2-assetic-route-and-resource-errors

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!