Symfony2:在树枝模板中使用扩展时出现ResourceNotFoundException [英] Symfony2: ResourceNotFoundException when using extends in a twig template

查看:105
本文介绍了Symfony2:在树枝模板中使用扩展时出现ResourceNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已覆盖以下目录中的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 'Symfony\Component\Routing\Exception\ResourceNotFoundException' 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屋!

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