使用 Zend 框架时显示 php 错误

2021-12-29 00:00:00 php zend-framework

我一直在使用 Zend Framework 并且遇到这个问题有一段时间了,但现在它变得太烦人了,所以我将问题发送给您.

I've been using Zend Framework and just living with this problem for a while, but it's now just gotten too annoying so i'll send the question out to you.

Zend 可以识别 Zend 框架内的某些问题(例如调用不存在的控制器),并将该问题发送到 ErrorController.我的工作正常.

There are certain problems within the Zend framework that Zend can recognize (such as calling a nonexistent controller), and will send that problem to the ErrorController. I've got that working fine.

似乎有一些问题,Zend Framework 会失败并通过 php 显示错误,例如某个函数不存在或什么的.那些我可以看到并修复的.

There seem to be some problems that Zend Framework will fail and display the error through php, like if a certain function doesn't exist or something. Those I can see and fix.

虽然有时 Zend 不会失败,但它也只会发送一个空响应.我会得到一个空白页.他们的布局没有显示,没有代码,没有任何东西可以让我知道出了什么问题.上次,有一个 require() 失败了.我不得不在没有反馈的情况下手动解决这个问题.

Sometimes though, Zend won't fail, but it will also just send out an empty response. I will get a blank page. They layout doesn't show up, there's no code, there's no nothing to give me an idea of what's gone wrong. Last time, there was a require() that failed. I had to manually figure this out with no feedback.

大家有没有遇到过这种情况?您对如何显示这些错误有什么建议吗?任何帮助将不胜感激!

Have any of you experienced this? Do you have any advice on how to get these errors to show? Any help would be appreciated!

推荐答案

框架的 MVC 组件的内部错误处理只能捕获异常,不能捕获 PHP 错误.

The internal error handling of the framework's MVC components can only trap Exceptions, not PHP errors.

为了在开发过程中协助调试,可以使用标准:

To assist in debugging during development, you can use the standard:

error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 'on');

此外,如果您使用的是 1.8 附带的新自动加载器,请使用:

Also, if you're using the new Autoloader included with 1.8, use:

Zend_Loader_Autoloader::getInstance()->suppressNotFoundWarnings(false);

允许发出失败的包含/要求语句.

To allow failed include/require statements to be issued.

相关文章