Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Using zf1.12
- --------------------------------------------------------------------------------------------
- App_ErrorController
- -------------------------
- class App_ErrorController extends Zend_Controller_Action
- {
- public function errorAction()
- {
- $this->view->Paths = $this->view->getHelper('Paths');
- $errors = $this->_getParam('error_handler');
- if (!$errors || !$errors instanceof ArrayObject) {
- $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:
- case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
- // 404 error -- controller or action not found
- $this->getResponse()->setHttpResponseCode(404);
- $priority = Zend_Log::NOTICE;
- $this->view->message = 'Page not found';
- break;
- default:
- // application error
- $this->getResponse()->setHttpResponseCode(500);
- $priority = Zend_Log::CRIT;
- $this->view->message = 'Application error';
- break;
- }
- // Log exception, if logger available
- if ($log = $this->getLog()) {
- $log->log($this->view->message, $priority, $errors->exception);
- $log->log('Request Parameters', $priority, $errors->request->getParams());
- }
- // conditionally display exceptions
- if ($this->getInvokeArg('displayExceptions') == true) {
- $this->view->exception = $errors->exception;
- }
- $this->view->request = $errors->request;
- }
- public function getLog()
- {
- $bootstrap = $this->getInvokeArg('bootstrap');
- if (!$bootstrap->hasResource('Log')) {
- return false;
- }
- $log = $bootstrap->getResource('Log');
- return $log;
- }
- }
- --------------------------------------------------------------------------------------------------
- Errors view file
- ------------------------------------------
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Zend Framework Default Application</title>
- </head>
- <body>
- <h1>An error occurred</h1>
- <h2><?php echo $this->message ?></h2>
- <?php if (isset($this->exception)): ?>
- <h3>Exception information:</h3>
- <p>
- <b>Message:</b> <?php echo $this->exception->getMessage() ?>
- </p>
- <h3>Stack trace:</h3>
- <pre><?php echo $this->exception->getTraceAsString() ?>
- </pre>
- <h3>Request Parameters:</h3>
- <pre><?php echo $this->escape(var_export($this->request->getParams(), true)) ?>
- </pre>
- <?php endif ?>
- </body>
- </html>
- ---------------------------------------------------------------------------------------------------
- application.ini file
- ----------------------------------------------
- [production]
- phpSettings.display_startup_errors = 1
- phpSettings.display_errors = 1
- includePaths.library = APPLICATION_PATH "/../library"
- autoloaderNamespaces[] = "Nirvana_"
- bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
- bootstrap.class = "Bootstrap"
- appnamespace = "Application"
- ;resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
- resources.frontController.params.displayExceptions = 1
- ; 2012-08-30
- resources.frontController.baseUrl = ""
- resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
- ; 2012-08-30 - for layouts/views
- resources.view[] =
- ; 2012-08-31 - for view helpers
- resources.view.helperPath = APPLICATION_PATH "/views/helpers"
- ; 2012-08-30 - for sessions
- resources.session.use_only_cookies = true
- resources.session.cookie_httponly = true
- resources.session.name = 'nirvana'
- resources.session.cookie_secure = false
- resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
- resources.modules[] =
- resources.frontController.params.prefixDefaultModule = "1"
- resources.frontController.defaultModule = "Application"
- [staging : production]
- [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
- resources.db.adapter = "PDO_PGSQL"
- resources.db.params.host = "localhost"
- resources.db.params.dbname = "test_nirvana"
- resources.db.params.username = "postgres"
- resources.db.params.password = "postgres"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement