简体   繁体   English

symfony错误500而不是生产中的404

[英]symfony error 500 instead 404 at production

my symfony project at production when an actions does not exist is throwing error 500 instead of 404. At dev enviroment, it shows error 404 (actually a debug of the 404 error says action not found). 在生产时我的symfony项目不存在操作时抛出错误500而不是404.在开发环境中,它显示错误404(实际上404错误的调试表示未找到操作)。

I am using custom 404 templates as manual says. 我正在使用自定义404模板作为手册说。

It sounds like the error is in your custom 404 action. 听起来好像是自定义404操作中的错误。 Can you provide the code for your 404 action and how you've defined your custom 404 in your settings.yml? 您是否可以提供404操作的代码以及如何在settings.yml中定义自定义404?

I was having the same issue where I was getting a 404 in debug, but a 500 in production. 我遇到了同样的问题,我在调试中获得了404,但是生产了500。 I know this isn't the answer for llazzaro's case since he marked Cyro as the correct answer, but here's what happened to me in case anyone else had a problem. 我知道这不是llazzaro案件的答案,因为他将Cyro标记为正确答案,但是如果其他人遇到问题,我发生了什么事。

My actions class was not extending sfActions , but was instead extending an intermediate class (which in turn extended sfActions ). 我的动作类没有扩展sfActions ,而是扩展了一个中间类(反过来扩展了sfActions )。 That intermediate class had a call to $this->getRoute() , which it was assuming returned an object, when in fact it can be null sometimes. 那个中间类调用了$this->getRoute() ,它假设返回了一个对象,实际上它有时可能为null。 Trying to access methods on a null object obviously failed, which caused the error 500. 尝试访问空对象上的方法显然失败,导致错误500。

I figured this out, (as Mike B suggested via comment on the original question), by checking my Apache logs. 通过检查我的Apache日志,我想出了这一点(正如Mike B建议通过对原始问题的评论)。 There was an error message there stating: 那里有一条错误消息:

PHP Fatal error: Call to a member function getRequirements() on a non-object in /path/to/apps/my_app/lib/sfIntermediateActions.php on line 46 PHP致命错误:在第46行的/path/to/apps/my_app/lib/sfIntermediateActions.php中的非对象上调用成员函数getRequirements()

Hope this helps anyone else who can't solve it from the other answer offered here! 希望这有助于其他任何无法解决的人从这里提供的其他答案!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM