views:

155

answers:

1

I have in my bootstrap

public function initRoutes()
{
    $router = new Zend_Controller_Router_Rewrite();
    $route = new Zend_Controller_Router_Route_Static('register', array('module'=>'members','controller'=>'register','action'=>'index'));
    $router->addRoute('register',$route);
}

and when I go to http://domain.com/register

I get this error:

The following error occurred:

exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (register)' in /var/www/html/beta/library/Zend/Controller/Dispatcher/Standard.php:241 Stack trace: #0 /var/www/html/beta/library/Zend/Controller/Front.php(936): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /var/www/html/beta/application/bootstrap.php(24): Zend_Controller_Front->dispatch() #2 /var/www/html/beta/public/index.php(8): require_once('/var/www/html/b...') #3 {main}

in the modules/members/controllers directory there is a RegisterController.php with the class Members_RegisterController

I am not sure what I am doing wrong, I have referred to the manual on static routes and it seems that this should work

+4  A: 

Looks like you are adding a route to a router, but the router is not the one that belongs to your front controller. The router you created evaporates as soon as your initRoutes() function terminates.

You must either use the default router of your front controller:

$router = $frontCtrl->getRouter();
$router->addRoute( ... );

Or else if you create a new router, set that router to be the router for the front controller:

$router = new Zend_Controller_Router_Rewrite();
// ...add routes...
$frontCtrl->setRouter($router);
Bill Karwin