Symfony2 错误 500 而不是 404 在生产中 [英] Symfony2 error 500 instead of 404 at production
问题描述
在我的 Symfony2 项目中,我进入了开发模式正确的 404 异常屏幕.但是我在生产模式下得到了 HTTP 状态代码 500 而不是 404 的空白屏幕.我正在使用位于 app/Resources/TwigBundle/views/Exception
中的自定义错误模板.在 apache 错误日志中,它会创建此消息:
In my Symfony2 project I'm getting at development mode correct 404 Exception screen. But I'm getting blank screen with HTTP status code 500 instead of 404 at production mode. I'm using custom error templates located in app/Resources/TwigBundle/views/Exception
. In apache error log it creates this message:
PHP Fatal error: Uncaught exception 'Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException' in /home/test/app/cache/prod/appprodUrlMatcher.php:518\nStack trace:
#0 /home/test/app/cache/prod/classes.php(1025): appprodUrlMatcher->match('/404')
#1 /home/test/app/cache/prod/classes.php(4550): Symfony\\Component\\Routing\\Router->match('/404')
#2 [internal function]: Symfony\\Bundle\\FrameworkBundle\\EventListener\\RouterListener->onKernelRequest(Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent))
#3 /home/test/app/cache/prod/classes.php(3777): call_user_func(Array, Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent))
#4 /home/test/app/cache/prod/classes.php(3703): Symfony\\Component\\EventDispatcher\\EventDispatcher->doDispatch(Array, 'kernel.request', Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent))
#5 /home/test/app/cache/prod/classes.php(4787): Symfony\\Component\\EventDispatcher\\EventDispatcher->dispatch('kernel.request', Object(Symfony\\Component\\HttpKernel\\Event\\Get in /home/test/app/cache/prod/classes.php on line 4560
推荐答案
Symfony\Component\Routing\Exception\ResourceNotFoundException
表示未定义的路由名称.看起来您的错误模板 {{ path('wrong_route') }}
中的某个位置.
Symfony\Component\Routing\Exception\ResourceNotFoundException
means undefined route name. It looks like you've got somewhere in your error template {{ path('wrong_route') }}
.
这篇关于Symfony2 错误 500 而不是 404 在生产中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!