Symfony2: ResourceNotFoundException when using extends in a twig template

岁酱吖の 提交于 2019-12-17 20:29:53

问题


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 'Symfony\Component\Routing\Exception\ResourceNotFoundException' in /Users/Aditya/Sites/Acme/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php on line 

Why is this?


回答1:


You're trying to generate a non-existant route in your template. Therefore the router throws the Exception.

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

for more detailed information.

Tip:

Sometimes you have routes only configured for the dev environment ( aka in routing_dev.yml ) and receive these errors in production.



来源:https://stackoverflow.com/questions/17510216/symfony2-resourcenotfoundexception-when-using-extends-in-a-twig-template

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