Symfony2 Assetic 路由和资源错误 [英] Symfony2 Assetic Route and Resource Errors

查看:53
本文介绍了Symfony2 Assetic 路由和资源错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有例如 index.html.php 的模板,我在其中使用了这样的 php 资产加载器

<?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;?>

如果我对模板文件进行任何更改,我会得到路由_assetic_2b431f4"不存在.

如果我改变了

<前>资产:使用控制器:假

我得到无法加载资源.".错误.

当我对文件进行一行更改时就会出现这种情况,因此有关缓存的一些信息.清除缓存没有帮助等.有什么想法吗?

解决方案

你必须进入 routing_dev.yml 并删除这些行:

_assetic:资源:.类型:资产

那么一切都应该正常了.

这里也给出了这个答案:

如何让 Symfony2 直接加载 CSS、JS 文件而不是通过 PHP?

如果你还没有这样做,请确保你已经完成了整个

php app/console assetic:dump

文档中给出的内容:

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

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?

解决方案

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

这篇关于Symfony2 Assetic 路由和资源错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆