为了方便调试,在index.php中可以设置$frontController->throwExceptions(true),这样所有错误会直接显示在浏览器中
但是最后部署时候,可以删除该句,并且增加application/Controller/ErrorController.php,以及/application/views/script/error/error.html来引导用户到一个错误提示页面
并且可以将错误记录到log文件中:
- <?php
- /** Zend_Controller_Action */
- require_once 'Gado/Controller/Action.php';
- require_once 'Zend/Log.php';
- require_once 'Zend/Log/Writer/Stream.php';
- class ErrorController extends Gado_Controller_Action
- {
- public function errorAction()
- {
- $errors = $this->_getParam('error_handler');
- $request = $this->getRequest();
- $exception = $errors->exception;
- $log = new Zend_Log(new Zend_Log_Writer_Stream('./log/applicationException.log'));
- $log->debug($request->getRequestUri());
- $log->debug(var_export($_POST, true) ."/n". var_export($_GET, true));
- $log->debug($exception->getMessage());
- $log->debug($exception->getTraceAsString());
- }
- }
- ?>