|
|||
|
First you have to make sure you can navigate to the error controller with your browser via http://localhost/error/error or http://localhost/default/error/error
If you get an "Object not found" error than you have to check your Apache httpd.conf and comment out: # Multi-language error messages #Include conf/extra/httpd-multilang-errordoc.conf because of this directive Apache maps /error to path_to_your_apache_installation/error folder, and not through the .htaccess file to index.php After you are sure that you ErrorController is working (you also need a scripts/error/error.phtml file), and it' accessible just make sure that you haven't set $frontController->throwExceptions(true) on your Front Controller, because it disables the ErrorHandler controller plugin. p.s. You don't need to register Zend_Controller_Plugin_ErrorHandler () with the Front controller using something like $frontController->registerPlugin (new Zend_Controller_Plugin_ErrorHandler ()); because the Zend_Controller_Plugin_ErrorHandler () is enabled by default. Hope this helps... Last edited by gog : 07-16-2008 at 10:54 AM. Reason: typo |
|
|||
|
Quote:
thanks heaps for the response, did everything you mentioned. I can access my error controller directly and it displays fine but it just doesn't get wanna wake up to an error. Below is what my front controller looks like: Code:
<?php
error_reporting(E_ALL|E_STRICT);
set_include_path(
'.' . PATH_SEPARATOR . '../../libraries'
. PATH_SEPARATOR . '../../systems/admin/models'
. PATH_SEPARATOR . '../../access/admin/widgets'
. PATH_SEPARATOR . '../../elements'
. PATH_SEPARATOR . get_include_path());
include "Zend/Loader.php";
Zend_Loader::registerAutoload();
$systemConfig = new Zend_Config_Ini('../../../configuration/system.ini', 'development');
$registry = Zend_Registry::getInstance();
$registry->set('system_config', $systemConfig);
$db = Zend_Db::factory($systemConfig->db);
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('db', $db);
$frontController = Zend_Controller_Front::getInstance();
$frontController->setControllerDirectory('../../systems/admin/controllers');
$router = $frontController->getRouter();
$router->addRoute('app', new Zend_Controller_Router_Route('apps/:appname', array('controller' => 'apps', 'action' => 'index')));
Zend_Layout::startMvc(array('layoutPath'=>'../../systems/admin/layouts'));$frontController->dispatch();
Can you please send me a working implementation of error controller? thanks. |
|
|||
|
Here's whats in my bootstrap.php:
Code:
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
date_default_timezone_set('Australia/Melbourne');
set_include_path('.' . PATH_SEPARATOR . '../library/'
. PATH_SEPARATOR . '../application'
. PATH_SEPARATOR . '../application/models'
. PATH_SEPARATOR . get_include_path());
include "Zend/Loader.php";
Zend_Loader::registerAutoload();
$config = new Zend_Config_Ini('../application/config.ini', 'default');
$registry = Zend_Registry::getInstance();
$registry->set('config', $config);
Zend_Layout::startMvc($config->appearance);
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(false);
$frontController->setControllerDirectory('../application/controllers');
$frontController->setBaseUrl('/');
$frontController->dispatch();
All mine has in it is: Code:
<?php
class ErrorController extends Zend_Controller_Action
{
public function init()
{
$this->view->baseUrl = $this->_request->getBaseUrl();
}
public function errorAction()
{
$this->view->title = "Error Page";
}
}
And all that contains is a custom error message. In my bootstrap I just change the flag in $frontController->throwExceptions(false); to true when I'm debugging. Al |
|
|||
|
I'm also pretty new to the Zend Framework and having no luck with the error controller either. I have a slightly different setup to the others, but nothing drastic. I have 3 'modules' defined - public (default), shared, and admin. Public uses the preDispatch method of the Zend_Controller_Plugin_Abstract:
PHP Code:
PHP Code:
HTML Code:
using: admin module
using: admin module
using: admin module
Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)'
in C:\Server\htdocs\cms\framework\Zend\Controller\Dispatcher\Standard.php:249
Stack trace:
#0 C:\Server\htdocs\cms\framework\Zend\Controller\Front.php(914):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 C:\Server\htdocs\cms\sites\site1\public\index.php(9):
Zend_Controller_Front->dispatch()
#2 {main} thrown in C:\Server\htdocs\cms\framework\Zend\Controller\Dispatcher\Standard.php on line 249
PHP Code:
Thanks in advance, Paul |
|
|||
|
Found a work around online (credit to Daniel Cousineau). Apparently the ZF does not allow for multiple error controllers by default - God knows why not - it is very useful to be able to handle errors differently for different modules...
PHP Code:
PHP Code:
|
|
|||
|
Brand new to Zend, but the above post is the answer. Luckily I actually wanted a single error handler for all of my modules, at least to start out with.
All I needed in my bootstrap was: Code:
$front->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(array(
'module' => 'error',
'controller' => 'error',
'action' => 'error'
)));
Works like a clock. Catches missing modules, missing controllers across different modules, etc. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|