25

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!

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Ethan
  • 5,660
  • 9
  • 44
  • 51

9 Answers9

32

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.

Alister Bulman
  • 34,482
  • 9
  • 71
  • 110
jason
  • 8,918
  • 2
  • 37
  • 43
  • It was the suppressNotFoundWarnings that I'd missed. Thank you so much! You have no idea how much time this saves me. – Ethan Jul 29 '09 at 17:18
  • That's strange because the manual says ZF doesn't do error suppression by default: http://framework.zend.com/manual/1.12/en/zend.loader.autoloader.html – The Unknown Dev Jul 27 '14 at 15:14
12

For others coming across this question: I changed the following line in configs/application.ini

resources.frontController.params.displayExceptions = 0

To:

resources.frontController.params.displayExceptions = 1

This allowed me to see the full Exception, including stacktrace.

Niels Bom
  • 8,728
  • 11
  • 46
  • 62
12

Set this in your config:

phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
Kamilos
  • 795
  • 2
  • 10
  • 25
8

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.

Brian
  • 81
  • 1
  • 1
7

It's too late to answer this question now. But hope it will help someone else...

Just place the following function in your Bootstrap.php file to enable exceptions..

protected function _initErrorDisplay(){
        $frontController = Zend_Controller_Front::getInstance();
        $frontController->throwExceptions(true);
    }
Jay Bhatt
  • 5,601
  • 5
  • 40
  • 62
  • May I ask, what you mean with your `enable` ? Is it logging the exception that was not logged before ? Or is it displaying the exception in the application view ? – Stephane Jun 23 '17 at 10:08
1

Open urproject/application/config and open application.ini
Change the second line:

phpSettings.display_errors = 0 

to

phpSettings.display_errors = 1

Now it will display errors.

Artemix
  • 2,113
  • 2
  • 23
  • 34
piyush
  • 11
  • 3
1

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)
Vasiliy Toporov
  • 814
  • 12
  • 27
0

For anybody for whom the answers given here didn't work, one can always go to the apache logs to see a description of the problem. It would of course be more convenient if this showed on the page, but I find it to be an acceptable alternative.

 /var/log/apache2/error.log

I have this file open with vim and type :e to refresh and G to go to the bottom of the page to see the most recent error when I get the blank page. It tells you the time the error occurred, the message and the line, so it's pretty helpful.

grasshopper
  • 3,988
  • 3
  • 23
  • 29
0

put these lines in application/configs/config.php

error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 'on');
Prabhagaran
  • 3,620
  • 1
  • 19
  • 19