Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
474 views
in Technique[技术] by (71.8m points)

php - Symfony2: ResourceNotFoundException when using extends in a twig template

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 

Why is this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...