簡體   English   中英

Symfony2:找不到產品404 = 200?

[英]Symfony2: prod not found 404 = 200?

在產品環境中,當請求不存在的URI(例如,... / green)時,我希望呈現自定義404錯誤頁面。 響應頭是

Date: Sat, 16 Nov 2013 19:11:55 GMT
Server: Apache/2.4.4 (Win32) PHP/5.4.8
X-Powered-By: PHP/5.4.16
Content-Length: 2455
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html

200 OK

響應是

Fatal error: Uncaught exception 'Symfony\Component\Routing\Exception\ResourceNotFoundException' in G:\Documents\workspace\sym\app\cache\prod\classes.php on line 1883 Symfony\Component\Routing\Exception\ResourceNotFoundException: in G:\Documents\workspace\sym\app\cache\prod\appProdUrlMatcher.php on line 1682 Call Stack: 0.0000 130880 1. {main}() G:\Documents\workspace\sym\web\app.php:0 0.0200 340984 2. Symfony\Component\HttpKernel\Kernel->handle() G:\Documents\workspace\sym\web\app.php:21 0.1800 2659792 3. Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle() G:\Documents\workspace\sym\app\bootstrap.php.cache:2249 0.1800 2661000 4. Symfony\Component\HttpKernel\HttpKernel->handle() G:\Documents\workspace\sym\app\bootstrap.php.cache:2947 0.1800 2661032 5. Symfony\Component\HttpKernel\HttpKernel->handleRaw() G:\Documents\workspace\sym\app\bootstrap.php.cache:2818 0.1800 2661576 6. Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() G:\Documents\workspace\sym\app\bootstrap.php.cache:2833 0.4900 4232624 7. Symfony\Component\EventDispatcher\EventDispatcher->dispatch() G:\Documents\workspace\sym\app\cache\prod\classes.php:1764 0.4900 4233384 8. Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() G:\Documents\workspace\sym\app\cache\prod\classes.php:1600 0.4900 4234080 9. call_user_func() G:\Documents\workspace\sym\app\cache\prod\classes.php:1667 0.4900 4234096 10. Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest() G:\Documents\workspace\sym\app\cache\prod\classes.php:1667 0.4900 4234360 11. Symfony\Component\Routing\Router->match() G:\Documents\workspace\sym\app\cache\prod\classes.php:1872 0.4900 4238400 12. appProdUrlMatcher->match() G:\Documents\workspace\sym\app\cache\prod\classes.php:1207 Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /green" in G:\Documents\workspace\sym\app\cache\prod\classes.php on line 1883 Call Stack: 0.0000 130880 1. {main}() G:\Documents\workspace\sym\web\app.php:0 0.0200 340984 2. Symfony\Component\HttpKernel\Kernel->handle() G:\Documents\workspace\sym\web\app.php:21 0.1800 2659792 3. Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle() G:\Documents\workspace\sym\app\bootstrap.php.cache:2249 

我越努力理解這一點,我就會越困惑。 文檔說,將在app\\Resources\\TwigBundle\\views\\Exception中呈現一個簡單的error404.html.twig (是的,我已經清除了產品緩存-多次!產品日志中沒有條目。)文檔是否錯誤,我真的需要創建一個異常處理程序來顯示此404頁面,因為響應是200?

更新:

所以我想在開發環境中使用404並不意味着它將在產品中使用404。 然后,我嘗試使用簡單的異常處理程序來獲取自定義錯誤頁面,但隨后沒有Monolog郵件。 由於自定義處理程序使用Twig,因此嘗試將自定義處理程序與Monolog集成在一起。 難怪我的頭在旋轉。

[Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException] Circular reference detected for service "router", path: "cache_warmer -> router -> monolog.logger.router -> mana.exception.controller -> templating -> twig -> templating.helper.logout_url".

並不是很明顯,該錯誤是由於錯誤的error404.html.twig文件引起的。 一旦更正,它將變得很有用。 道歉。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM