ZF-11645: Error when set dispatch on front controller
Description
When I attempt set the dispatcher on my bootstrap file, the system generate an exception.
Ex.
class My_Dispatcher extends Zend_Controller_Dispatcher_Standard
{
}
class My_Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
...
public function _initMyFrontController()
{
$this->bootstrap('frontController');
$frontController = $this->getResource('frontController');
$frontController->setDispatcher(new My_Dispatcher());
return $frontController;
}
...
}
Exception:
Fatal error: Uncaught exception 'Zend_Application_Bootstrap_Exception' with message 'No default controller directory registered with front controller' in /home/jpfaria/public/apps/MenuTabletAdmin/library/Zend/Application/Bootstrap/Bootstrap.php:91 Stack trace: #0 /home/jpfaria/public/apps/MenuTabletAdmin/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #1 /home/jpfaria/public/apps/MenuTabletAdmin/public/index.php(25): Zend_Application->run() #2 {main} thrown in /home/jpfaria/public/apps/MenuTabletAdmin/library/Zend/Application/Bootstrap/Bootstrap.php on line 91
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2011-08-04T20:47:51.000+0000
It looks to me like you're missing a directive in your configuration -- in INI format, this:
Also, you're not naming your bootstrap "Bootstrap" (no namespace), so you'll need to tell Zend_Application the bootstrap class name as well:
If those are already in your configuration, can you provide your full configuration, as well as the contents of your public/index.php file, please?
Posted by João Paulo de Oliveira Faria (jpfaria) on 2011-08-04T21:08:18.000+0000
Thank you for your quick post.
All settings are being passed perfectly. The proof of this is that if I modify the method getDispatcher of FrontController to:
public function getDispatcher() { /** * Instantiate the default dispatcher if one was not set. */ if (!$this->_dispatcher instanceof Zend_Controller_Dispatcher_Interface) { require_once 'My/Dispatcher.php'; $this->_dispatcher = new My_Dispatcher(); } return $this->_dispatcher; }Works perfectly.