Page 1 of 1

Zend controller -- invoke exceptions???

Posted: Wed Apr 22, 2009 1:15 pm
by alex.barylski
I am receiving the following exception:
Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in /var/www.mydomain.com/libs/Zend/Controller/D ... rd.php:241 Stack trace: #0 /var/www.mydomain.com/libs/Zend/Controller/Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /var/www.mydomain.com/public/index.php(28): Zend_Controller_Front->dispatch() #2 {main} thrown in /var/www.mydomain.com/libs/Zend/Controller/D ... andard.php on line 241
Here is my invocation code:

Code: Select all

 
  define('CLIQUE_APPLICATION_CLASSES_PATH', '/var/www.cliquecanada.com/core/classes/');
 
  set_include_path(CLIQUE_LIBRARY_PATH);
  //Zend_Controller_Front::run(CLIQUE_APPLICATION_CLASSES_PATH);
 
  //Zend_Controller_Front::getInstance()->dispatch();
 
  $front = Zend_Controller_Front::getInstance();
  $front->setControllerDirectory(CLIQUE_APPLICATION_CLASSES_PATH);
  $front->dispatch();
My controller looks like:

Code: Select all

 
<?php
 
  class IndexController extends Zend_Controller_Action{
 
    public function indexAction()
    {
      echo 'This is the default action executed.';
    }
 
  }
 
It's located at the path:

Code: Select all

/var/www.cliquecanada.com/core/classes/IndexController.php
Here is what the controller looks like right before calling dispatch() method on $front:

Code: Select all

Zend_Controller_Front Object
(
    [_baseUrl:protected] => 
    [_controllerDir:protected] => 
    [_dispatcher:protected] => Zend_Controller_Dispatcher_Standard Object
        (
            [_curDirectory:protected] => 
            [_curModule:protected] => default
            [_controllerDirectory:protected] => Array
                (
                    [default] => /var/www.mydomain.com/core/classes
                )
 
            [_defaultAction:protected] => index
            [_defaultController:protected] => index
            [_defaultModule:protected] => default
            [_frontController:protected] => 
            [_invokeParams:protected] => Array
                (
                )
 
            [_pathDelimiter:protected] => _
            [_response:protected] => 
            [_wordDelimiter:protected] => Array
                (
                    [0] => -
                    [1] => .
                )
 
        )
 
    [_invokeParams:protected] => Array
        (
        )
 
    [_moduleControllerDirectoryName:protected] => controllers
    [_plugins:protected] => Zend_Controller_Plugin_Broker Object
        (
            [_plugins:protected] => Array
                (
                )
 
            [_request:protected] => 
            [_response:protected] => 
        )
 
    [_request:protected] => 
    [_response:protected] => 
    [_returnResponse:protected] => 
    [_router:protected] => 
    [_throwExceptions:protected] => 
)
Why is framework not finding (invoking) my controller? What am I missing?

Cheers,
Alex

Re: Zend controller -- invoke exceptions???

Posted: Wed Apr 22, 2009 1:49 pm
by Christopher
I just glanced at your post, but I think it should be:

/var/www.cliquecanada.com/core/classes/controllers/IndexController.php

Re: Zend controller -- invoke exceptions???

Posted: Thu Apr 23, 2009 7:49 am
by alex.barylski
I had tried that and it didn't seem to do the trick but oddly when I disabled:

Code: Select all

 $front->setParam('noErrorHandler', true);
  $front->setParam('noViewRenderer', true);
Everything started working as expected... :roll:

Just curious, the default router...it'll process URI requests like /blog/list by default?

Re: Zend controller -- invoke exceptions???

Posted: Thu Apr 23, 2009 1:05 pm
by Eran
Everything started working as expected...
It's not that confusing actually - you had the viewRenderer on, which means each action is automatically rendered. Since you probably didn't have the matching view template for your index action, it was invoking an error. It attempted to call the defualt error handler, which is a controller called ErrorController, but didn't find that. So that's the exception you were getting.
The default error handler is quite useful to show graceful error pages instead of PHP errors.

Re: Zend controller -- invoke exceptions???

Posted: Fri Jun 12, 2009 12:24 pm
by sukhdeep
Wow this post helped me out a lot. I've been scouring the net looking for a solution to the same problem and this post really cleared things up for me. Thanks a lot guys :)