2

In my ZF project's application.ini, I've set "resources.frontController.params.displayExceptions = 1". However, if an exception is thrown, the exception isn't displayed in the browser.

Looking at the code in the generated ErrorController.php, it looks like the line that says:

if ($this->getInvokeArg('displayExceptions') == true)

always fails this condition.

I'm new to the ZF, so there's likely something obvious I'm missing - but I don't know why it's not being set. It does seem to be processing the application.ini file, as it would be failing to connect to my database if it wasn't.


EDIT

Just found a clue:

I had changed my modules directory. I've just undone that change, and this problem no longer occurs. However, I do actually want to change the modules directory. Here's a list of the changes I had made:

In my application.ini, I added:

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

In my Bootstrap class, I added:

protected function _initFrontController()
{
    $front = Zend_Controller_Front::getInstance();
    $front->addModuleDirectory(dirname(__FILE__) . '/modules');
    $front->setDefaultModule('frontend');

    return $front;
}

This seems to successfully handle the module's new location and the site works fine (except that the displayExceptions flag isn't being set properly).

Any ideas why this would be causing this symptom?

Dan
  • 5,692
  • 3
  • 35
  • 66
  • What does the debugger tell you? Or Zend_Debug::dump() for these variables? – markus May 04 '11 at 13:36
  • @markus What variables should I be looking at? Sorry, I'm new to ZF, so not really sure how to programmatically access those application.ini settings. I tried dumping out Zend_Controller_Front::getInstance()->getParams(), but that didn't have anything useful in it. – Dan May 04 '11 at 14:21
  • What is your application environment? Usually it should be set to `development` in order to display exceptions. – Vika May 04 '11 at 14:24

3 Answers3

4

I have in _initAutoload in boostrap file

$modelLoader = new Zend_Application_Module_Autoloader ( array (
              'namespace' => '', 
              'basePath' => APPLICATION_PATH . '/modules/default' ) );

and in application.ini

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules = ''
resources.frontController.params.displayExceptions = 1

and it works fine for me. It seems that your module configuration was not correct. However I created m zf project using cli tool which does all the configuration.


Actually the suppressNotFoundWarnings(false) solved it for me when I had that problem. However I found a possible dublicates Display php errors when using Zend framework and How do I display exception errors thrown by Zend framework and Zend Framework - not all errors are shown

Good luck!


This may solve your problem. In your application boostrap file in the _initAutoload function add following statement

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

when in development mode as then the new autoloader will actually tell you what the syntax error is rather than showing you a white page.


Maybe you are missing more information in your application.ini file. In my application.ini I have

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
Community
  • 1
  • 1
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
  • Unfortunately that doesn't work either :( I'll try and do a bit of digging into the Zend code to see what it's doing underneath. – Dan May 04 '11 at 18:20
  • hm actually there isn't anything you can do that wasn't already suggested by the answers. See my update, maybe that helps ;) – DarkLeafyGreen May 04 '11 at 19:16
  • I've found a clue! :) See my update in the initial post. I must be doing something wrong when changing the modules directory. Not sure what though! – Dan May 04 '11 at 19:24
  • Glad that you solved that. I added some thoughts to my answer. – DarkLeafyGreen May 04 '11 at 19:59
  • Thanks for that. Unfortunately, it's still not working. I've given up for the time being, and have commented out that if statement in my error controller so that it always shows the error. Obviously will remove before going live! Hopefully I'll have found the problem by then! Thanks for your help. – Dan May 04 '11 at 20:39
1

I had this same issue and traced it back to the .ini file.

For me, the displayExceptions value from the .ini was not read in the ErrorController due to the case sensitivity of the .ini file.

Try changing all of the instances of "frontController" to "frontcontroller" (remove the capitalization from the C in controller) and it should solve your problem.

Before:

resources.frontController.params.displayExceptions = 1

After (lowercase C):

resources.frontcontroller.params.displayExceptions = 1
BPosey
  • 58
  • 4
0

Finally worked it out. My bootstrap initialisation was happening in the wrong order. I fixed it by completely removed this bootstrap method:

protected function _initFrontController()
{
    $front = Zend_Controller_Front::getInstance();
    $front->addModuleDirectory(dirname(__FILE__) . '/modules');
    $front->setDefaultModule('frontend');

    return $front;
}

And then instead putting the first three lines of it in the _initAutoLoad method above where I set my autoload settings.

Dan
  • 5,692
  • 3
  • 35
  • 66