ethereal1m Posted May 19, 2010 Share Posted May 19, 2010 Dear all, I'm using Zend Framework 1.10 with the following index.php file: defined('APPLICATION_PATH') || define('APPLICATION_PATH', '/srv/httpd/htdocs/Zend/application'); // Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); // Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/../library'), get_include_path(), ))); /** Zend_Application */ require_once 'Zend/Application.php'; // Create application, bootstrap, and run $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); //$application->bootstrap()->run(); and my indexController.php looks like: class IndexController extends Zend_Controller_Action { public function init() { $this->_helper->viewRenderer->setNoRender(); } public function indexAction() { $this->getResponse()->appendBody('Hello from indexAction'); } } Also it has application.ini file: [production] phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 includePaths.library = APPLICATION_PATH "/../library" bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" [staging : production] [testing : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 [development : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 But when I debug the script looking at Zend_Application_Bootstrap_Bootstrap class on Bootstrap.php when running its run() function, inside it, Zend_Controller_Front object variable _cotrollerDir is not initialized, whereas bootstrap object ->options->resources->frontController->controllerDirectory is set. Also I got the following error (exception): Zend_Controller_Dispatcher_Exception: Invalid controller specified (error) in /var/www/htdocs/Zend/library/Zend/Controller/Dispatcher/Standard.php on line 242 So how come the controller directory is not recognized by Zend_Controller_Front? Any ideas? Regards, ethereal1m Quote Link to comment https://forums.phpfreaks.com/topic/202241-zend_controller_dispatcher_exception-invalid-controller-specified-error/ Share on other sites More sharing options...
ignace Posted May 19, 2010 Share Posted May 19, 2010 You have an error and it's trying to dispatch ErrorController which you are missing. class ErrorController extends Zend_Controller_Action { public function errorAction() { $errorHandler = $this->_getParam('error_handler'); var_dump($errorHandler);//does this contain an exception property? print $errorHandler->exception->getMessage(); } } Quote Link to comment https://forums.phpfreaks.com/topic/202241-zend_controller_dispatcher_exception-invalid-controller-specified-error/#findComment-1060466 Share on other sites More sharing options...
ethereal1m Posted May 19, 2010 Author Share Posted May 19, 2010 Which part in my code that try to dispatch errorController? The indexController is there, I just modified my message, you are replying just a little bit too fast Quote Link to comment https://forums.phpfreaks.com/topic/202241-zend_controller_dispatcher_exception-invalid-controller-specified-error/#findComment-1060467 Share on other sites More sharing options...
ethereal1m Posted May 19, 2010 Author Share Posted May 19, 2010 the error comes when I'm loading my index.php... what is this to do with errorController? I'm confused. Quote Link to comment https://forums.phpfreaks.com/topic/202241-zend_controller_dispatcher_exception-invalid-controller-specified-error/#findComment-1060470 Share on other sites More sharing options...
ignace Posted May 19, 2010 Share Posted May 19, 2010 Whenever you get an error (read Exception) your dispatcher will catch this otherwise uncaught Exception (to remain functional towards your end-users) and create an error handler (Zend_Controller_Plugin_ErrorHandler) object, add it to the internal messaging system, sets the active controller to ErrorController, and signals the dispatcher the request is yet unhandled (isDispatched(false)). So your dispatcher tries to find and execute ErrorController which it can't find and therefor throws an Exception that isn't caught as the Dispatcher itself doesn't handle it's own Exception's. In order to work with the Zend framework you need a deep understanding of it's internal workings. I suggest you familiarize yourself before digging any deeper as it's only getting more and more complex with each new release. Quote Link to comment https://forums.phpfreaks.com/topic/202241-zend_controller_dispatcher_exception-invalid-controller-specified-error/#findComment-1060475 Share on other sites More sharing options...
ethereal1m Posted May 19, 2010 Author Share Posted May 19, 2010 well,ironically I'm learning zend framework by following a book hence stumbling upon this problem. But the book is using 1.8 ver and i'm using 1.10 lib, not sure if the version discrepancy is something to do with the error. can i disable the error handler? like (I found this on the web but don't know how to incorporate it: $this->frontController->setParam('noErrorHandler', TRUE); or are you saying I should incorporate your ErrorController instead? Also how come my controller directory is not recognized by the frontController? Quote Link to comment https://forums.phpfreaks.com/topic/202241-zend_controller_dispatcher_exception-invalid-controller-specified-error/#findComment-1060484 Share on other sites More sharing options...
ignace Posted May 19, 2010 Share Posted May 19, 2010 It has nothing to do with the version difference. And it's best to not disable the error handler as you otherwise will not be notified of any occured error's returning a blank page. And yes you should incorporate the ErrorController, it will tell you what the error is. Quote Link to comment https://forums.phpfreaks.com/topic/202241-zend_controller_dispatcher_exception-invalid-controller-specified-error/#findComment-1060486 Share on other sites More sharing options...
ethereal1m Posted May 19, 2010 Author Share Posted May 19, 2010 hmm, i created errorController.php with the code that you gave me, it still throws me the same error. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/202241-zend_controller_dispatcher_exception-invalid-controller-specified-error/#findComment-1060604 Share on other sites More sharing options...
ignace Posted May 19, 2010 Share Posted May 19, 2010 hmm, i created errorController.php with the code that you gave me, it still throws me the same error. Any ideas? It has been a while since I used Zend framework I added a comment to my code that said you should check out what the error_handler object returned. Quote Link to comment https://forums.phpfreaks.com/topic/202241-zend_controller_dispatcher_exception-invalid-controller-specified-error/#findComment-1060639 Share on other sites More sharing options...
ethereal1m Posted May 24, 2010 Author Share Posted May 24, 2010 I just realized that I should have executed a shell script zf.sh that comes with the framework and creates bunch of files, one of them is ErrorController. Now it's fixed. thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/202241-zend_controller_dispatcher_exception-invalid-controller-specified-error/#findComment-1062549 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.