Symfony2:在树枝模板中使用扩展时出现 ResourceNotFoundException [英] Symfony2: ResourceNotFoundException when using extends in a twig template
问题描述
我已经覆盖了以下目录中的 exception.html.twig:
I have over-ridden the exception.html.twig in the following directory:
app/Resources/TwigBundle/views/Exception
我想扩展另一个包中的另一个树枝,因此我执行了以下操作:
I have another twig inside another bundle that I'd like to extend, so I did the following:
{% extends 'AcmeMainBundle::layout.html.twig' %}
但它总是给我这个错误:
but it always gives me this error:
Fatal error: Uncaught exception 'SymfonyComponentRoutingExceptionResourceNotFoundException' in /Users/Aditya/Sites/Acme/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php on line
这是为什么?
推荐答案
您正试图在模板中生成不存在的路由.因此路由器抛出异常.
You're trying to generate a non-existant route in your template. Therefore the router throws the Exception.
检查你的模板是否有像 path()
这样的路由生成调用,并确保所有使用的路由名称确实存在.之前清除缓存以确保您有可用的最新路线.
Examine your template for route-generating calls like path()
and make sure all used route-names actually exist. Clear your cache before to be sure you have the latest routes available.
您可以使用控制台命令调试您的路由...
you can debug your routing with the console command ...
app/console router:debug --env=prod
app/console router:debug --env=dev
.. 列出应用程序中的所有路由.进一步使用...
.. to list all routes in your application. Further use ...
app/console router:debug route_name
了解更多详细信息.
提示:
有时您只为开发环境配置了路由(又名routing_dev.yml)并在生产中收到这些错误.
Sometimes you have routes only configured for the dev environment ( aka in routing_dev.yml ) and receive these errors in production.
这篇关于Symfony2:在树枝模板中使用扩展时出现 ResourceNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!