i create 3 module for my proj like this:
application/module/admin
application/module/default
application/module/error
every module has itself cnotroller , view , layout folder. every things is correct in default module, but when i go to admin module i saw this error (www.domain.com/public/admin)
Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller class ("Error_ErrorController")' in E:\xampp\php\PEAR\Zend\Controller\Dispatcher\Standard.php:347 Stack trace: #0 E:\xampp\php\PEAR\Zend\Controller\Dispatcher\Standard.php(256): Zend_Controller_Dispatcher_Standard->loadClass('ErrorController') #1 E:\xampp\php\PEAR\Zend\Controller\Front.php(946): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Req开发者_如何转开发uest_Http), Object(Zend_Controller_Response_Http)) #2 E:\zend_progamming\donyaye_fan_zend\application\Bootstrap.php(110): Zend_Controller_Front->dispatch() #3 E:\zend_progamming\donyaye_fan_zend\public\index.php(5): Bootstrap->runApp() #4 {main} thrown in E:\xampp\php\PEAR\Zend\Controller\Dispatcher\Standard.php on line 347
this is my bootstrap code that has relation with this error:
$frontController->addModuleDirectory(ROOT_DIR . '/application/modules');
$frontController->setDefaultModule('default');
$frontController->registerPlugin(new Places_Controller_Plugin_ModuleSetup());
$frontController->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(array(
'module' => 'error',
'controller' => 'error',
'action' => 'error'
)));
and this is my modulesetup class:
class Places_Controller_Plugin_ModuleSetup extends Zend_Controller_Plugin_Abstract{ public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
// Set the layout directory for the loaded module
$layoutPath = ROOT_DIR . '/application/modules/' . $request->getModuleName() . '/layouts/scripts/';
Zend_Layout::startMvc(array('layoutPath' =>$layoutPath));
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => ROOT_DIR . "/modules/",
));
$autoloader->addResourceTypes(array(
'admin' => array(
'path' => 'admin/',
'namespace' => 'admin'
),
'error' => array(
'path' => 'error/',
'namespace' => 'error')));
}
}
i found the answer : in errorController must put error directory name befor class name ,like error_errorController
errorControl.php is not available in your controllers folder. if this file will available on their place custom error will show from errorControl.php file .
Main problem is: your code have some error in php file , so that program is searching errorControl.php file . if you will remove error from php file this error will not come.
精彩评论