Zend controller -- invoke exceptions???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Zend controller -- invoke exceptions???

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Zend controller -- invoke exceptions???

Post by Christopher »

I just glanced at your post, but I think it should be:

/var/www.cliquecanada.com/core/classes/controllers/IndexController.php
(#10850)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Zend controller -- invoke exceptions???

Post 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?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Zend controller -- invoke exceptions???

Post 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.
sukhdeep
Forum Newbie
Posts: 1
Joined: Fri Jun 12, 2009 12:19 pm

Re: Zend controller -- invoke exceptions???

Post 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 :)
Post Reply