Zend_Controller_Dispatcher_Exception

Over the past week I have been learning and working with Zend Framework on a new site im creating, 20DollarBanners.com.  Everything has been working great all week on my windows machine, and I thought it was about time to upload to one of our live web servers for testing.  As with most sites, as soon as I went from Windows to Linux all hell broke out.   I got the following error, and couldn’t see anywhere in the code why it was happening.

exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Invalid controller specified (index)’ in /home/username/library/Zend/Controller/Dispatcher/Standard.php:249 Stack trace: #0 /home/username/library/Zend/Controller/Front.php(914): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /home/username/public_html/index.php(54): Zend_Controller_Front->dispatch() #2 {main}

After a little playing around on my local machine, I managed to reproduce the same error, and found that it was a problem with the filenames of my controller files.  I checked on the linux server, and everything looked in order apart from one small difference.  The filename on the server was indexController instead of IndexController, the captial I made all the difference.

After googling the problem, all I found was a load of results with pages just showing the error message, so hopefully this blog post will be of use to anyone else who finds themselves in the same situation I did.

12 Responses to “Zend_Controller_Dispatcher_Exception”

  1. mike says:

    The following is the error msg. Seem to be everything right. Do not know why i got this error

    Fatal error: Uncaught exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Invalid controller specified (error)’ in /var/www/html/phpweb20/include/Zend/Controller/Dispatcher/Standard.php:241 Stack trace: #0 /var/www/html/phpweb20/include/Zend/Controller/Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /var/www/html/phpweb20/htdocs/index.php(17): Zend_Controller_Front->dispatch() #2 {main} thrown in /var/www/html/phpweb20/include/Zend/Controller/Dispatcher/Standard.php on line 241

  2. Brooke Bryan says:

    Does your ErrorController exist and the correct case on the filename?

    Here is an basic error controller:

    /**
    * ErrorController - The default error controller class
    *
    * @author
    * @version
    */

    require_once 'Zend/Controller/Action.php';

    class ErrorController extends Zend_Controller_Action
    {

    /**
    * This action handles
    * - Application errors
    * - Errors in the controller chain arising from missing
    * controller classes and/or action methods
    */
    public function errorAction()
    {
    $errors = $this->_getParam('error_handler');
    switch ($errors->type) {
    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()->setRawHeader('HTTP/1.1 404 Not Found');
    $this->view->title = 'HTTP/1.1 404 Not Found';
    break;
    default:
    // application error; display error page, but don't change
    // status code
    $this->view->title = 'Application Error';
    break;
    }

    $this->view->message = $errors->exception;
    }
    }

  3. Rafael says:

    Hi Brooke, super model name btw : )

    I have struggled with the same error:

    Fatal error: Uncaught exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Invalid controller specified (error)’ in C:\wamp\www\XXX\library\Zend\Controller\Dispatcher\Standard.php:241 Stack trace: #0 C:\wamp\www\XXX\library\Zend\Controller\Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 C:\wamp\www\XXX\html\index.php(48): Zend_Controller_Front->dispatch() #2 {main} thrown in C:\wamp\www\XXX\library\Zend\Controller\Dispatcher\Standard.php on line 241

    And thank to you I gained some insight into the inner workings of the framework. But for me the issue was porting the include path in index.php from Windows to Unix and viceversa:

    Windows version:
    define(‘APPLICATION_PATH’, realpath(dirname(__FILE__) . ‘/../application/’));
    set_include_path(
    APPLICATION_PATH . ‘/../library’
    . PATH_SEPARATOR . get_include_path()

    Unix version:
    define(‘APPLICATION_PATH’, realpath(dirname(__FILE__) . ‘../application/’));
    set_include_path(
    APPLICATION_PATH . ‘../library’
    . PATH_SEPARATOR . get_include_path()

    So just get rid off the first “/” and ta-da! no errors.

  4. Rafael says:

    Alright I’ve gone mad! Now it works with the “/” on Unix go figure… arrg!

  5. jannej says:

    Had the same problems when deployed my project. Thanks! Your tip saved my day, I owe you one! ;-)

  6. Porno says:

    Hi,
    you saved me a couple of additional minutes googling:)

    IMPORTANT for DREAMWEAVER users:

    I have changed name of my file from indexController.php to IndexController.php and i’ve uploaded it in Dreamweaver but i still had the same error.

    After a while i’ve just checked remote folder and there were two files! indexController.php and IndexController.php

    After deleting indexController.php problem was solved;D

    Thanks!

  7. leonking says:

    thank you very much ! It works After indexController.php to IndexController.php .Buy in my appinon, the first captial should be lower? Why it is capital?

  8. Thanh Tung says:

    very thank you

  9. The way you have described this is very thorough. I will link your blog page to mine.

  10. phạm thành lập says:

    thankyou Rafael

  11. Daniele says:

    Thank you!!!!!!!

    After searching for hours, this tip saved me.

    Thanks and best regards,
    Daniele.

  12. guan says:

    你好,我遇到了相同的问题!hello,I have struggled with the same error.
    我的英文很烂。。。my english is very poor,so I give my solution directly here。
    ———————-
    $controller = Zend_Controller_Front::getInstance();
    $controller->setControllerDirectory(INCLUDE_PATH.’/Controllers’);
    $controller->setParam(‘useDefaultControllerAlways’, true);


Leave a Reply