zend框架错误控制器未处理异常_NO_controller


zend framework error controller not handling EXCEPTION_NO_CONTROLLER

在我的Zend Framework项目中,错误控制器没有处理EXCEPTION_NO_controller异常。当我调试Error控制器时,它确实进入了EXCEPTION_NO_controller开关块,并完成了方法中的每一步,但我的Error.phtml没有被呈现。它显示的是致命错误,而不是error.phtml视图。它处理EXCEPTION_NO_ACTION和默认块,并呈现error.phtml视图。我不明白问题出在哪里,也不明白我错过了什么。

以下是我在错误控制器代码中的错误操作:

 public function errorAction()
 {
    $errors = $this->_getParam('error_handler');
    if (!$errors) {
        $this->view->message = 'You have reached the error page';
        return;
    }
    switch ($errors->type) {
        case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
        case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            // 404 error -- controller or action not found
            $this->getResponse()->setHttpResponseCode(404);
            $this->view->message = 'no such module exist';
            break;
        case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
            // 404 error -- controller or action not found
            $this->getResponse()->setHttpResponseCode(404);
            $this->view->message = 'no such module exist';
            break;
        default:

            $this->getResponse()->setHttpResponseCode(500);
            $this->view->message = 'an application error occurred';
            break;
    }
    // Log exception, if logger available
    //if ($log == $this->getLog()) {
    //    $log->crit($this->view->message, $errors->exception);
    //}
    // conditionally display exceptions
    if ($this->getInvokeArg('displayExceptions') == true) {
        $this->view->exception = $errors->exception;
    }
    $this->view->request   = $errors->request;
}

当我输入任何无效的控制器时,我会收到以下致命错误:

Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script' not found in path .....................

以下是我的index.php

// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV')     :   'development'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
set_include_path(implode(PATH_SEPARATOR, array(
'/home/sampleproj/www/library/',
    get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
        ->run();

您需要在文件夹/scripts/errors/ 中创建视图文件error.phtml(带有一些htlm代码)