5.2. Using a router
Prev | Chapter 5. Zend_Controller_RewriteRouter | Next

## 5.2. Using a router

To properly use the RewriteRouter you have to instantiate it, add some user defined routes and inject it into the controller. The following code illustrates the procedure:

    /* -- create a router -- */

    $router = new Zend_Controller_RewriteRouter();
    $router->addRoute('user', 'user/:username', array('controller' => 'user', 'action' => 'info'));

    /* -- set it in a controller -- */

    $ctrl = Zend_Controller_Front::getInstance();
    $ctrl->setRouter($router);

Prev | Up | Next
Chapter 5. Zend_Controller_RewriteRouter | Home | 5.3. Basic Routes