2011-05-04 13:09
浏览 33

Zend Framework - displayExceptions属性不起作用

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.


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

    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?

图片转代码服务由CSDN问答提供 功能建议

在我的ZF项目的application.ini中,我设置了“resources.frontController.params.displayExceptions = 1”。 但是,如果抛出异常,则浏览器中不会显示异常。


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


我是ZF的新手,所以很可能会有一些我不知道的东西 - 但我不知道为什么它没有被设置。 它似乎正在处理application.ini文件,因为它不能连接到我的数据库,如果不是。



我更改了模块目录。 我刚刚撤消了这个改变,这个问题不再发生了。 但是,我确实想要更改模块目录。 以下是我所做的更改列表:


  resources.frontController.moduleDirectory =  APPLICATION_PATH“/ modules”


  protected function _initFrontController()\  n {
 $ front = Zend_Controller_Front :: getInstance(); 
 $ front-> addModuleDirectory(dirname(__ FILE__)。'/ modules'); 
 $ front-> setDefaultModule('frontend'); 
返回$ front; 

这似乎成功处理了模块的新位置,网站工作正常(除了displayExceptions标志不是 设置正确)。


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dougan7523 2011-05-06 12:51

    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');
        return $front;

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

    解决 无用
    打赏 举报

相关推荐 更多相似问题