Display php errors when using Zend framework

2019-01-17 03:38发布

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.

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.

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.

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!

9条回答
▲ chillily
2楼-- · 2019-01-17 04:26

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');

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.

查看更多
在下西门庆
3楼-- · 2019-01-17 04:26

Edit the file public/index.php.
Change the APPLICATION_ENV to 'development'.

This will use the development settings in your application/configs/application.ini file. Those settings define whether to suppress errors.

查看更多
等我变得足够好
4楼-- · 2019-01-17 04:29

Fast and dirty decision, if none of already mentioned methods worked (useful for old or ugly-configured version of ZF):

  • find ErrorController of your application.
  • put the call of debug_print_backtrace function at the top of init method (with die() optionally)
查看更多
登录 后发表回答