Zend Framework - ErrorHandler似乎没有按预期工作

时间:2008-09-18 00:30:05

标签: php zend-framework

这是我第一次使用Zend Framework。我正在尝试按照Quick Start教程。一切都按预期工作,直到我到达Error Controller and View的部分。当我导航到一个不存在的页面时,我没有收到错误页面,而是获得致命错误屏幕转储(完全是它的荣耀):

  

致命错误:未捕获的异常'Zend_Controller_Dispatcher_Exception'   消息'指定了无效的控制器(错误)'   /home/.fantasia/bcnewman/foo.com/library/Zend/Controller/Dispatcher/Standard.php:249   堆栈跟踪:#0   /home/.fantasia/bcnewman/foo.com/library/Zend/Controller/Front.php(946):   Zend_Controller_Dispatcher_Standard->调度(对象(的Zend_Controller_Request_Http),   对象(Zend_Controller_Response_Http))#1   /home/.fantasia/bcnewman/foo.com/public/index.php(42):   抛出Zend_Controller_Front-> dispatch()#2 {main}   /home/.fantasia/bcnewman/foo.com/library/Zend/Controller/Dispatcher/Standard.php   在第249行

我不相信这是由我的语法错误引起的(复制并粘贴了教程中的示例文件的内容),我相信我的应用程序目录结构是正确的:

./application
./application/controllers
./application/controllers/IndexController.php
./application/controllers/ErrorHandler.php
./application/views
./application/views/scripts
./application/views/scripts/index
./application/views/scripts/index/index.phtml
./application/views/scripts/error
./application/views/scripts/error/error.phtml
./application/bootstrap.php
./public
./public/index.php

最后,IndexControllerindex.phtml视图确实有效。

2 个答案:

答案 0 :(得分:4)

你有ErrorHandler.php。它应该是ErrorController.php。控制器都需要按照NameController.php的格式命名。由于您没有正确命名,调度员无法找到它。

答案 1 :(得分:2)

假设您已将ErrorController插件加载到前端控制器中,请确保您的引导程序中没有以下设置:

$frontController->throwExceptions(true);

如果设置了此项,则无论是否设置了错误控制器,异常都将始终