Mapping URLs to action parameters (Zend Framework)

Suppose you want to map /fetch/ to the fetch action within the Fetch controller with as a parameter. Zend Framework allows you to create a regex route for this purpose.

Fetch controller with a fetch action


class FetchController extends Zend_Controller_Action {

    public function init() {
        /* Initialize action controller here */

    public function indexAction() {
        // action body

    public function fetchAction() {
        $fetchParameter = $this->getRequest()->getParam('fetchParameter');
        $this->view->fetchParameter = $fetchParameter;



Modify Bootstrap.php to add a new costco viagra. regex route.

     	$frontController = Zend_Controller_Front::getInstance();
        $router = $frontController->getRouter();

	$routeFetch = new Zend_Controller_Router_Route_Regex (
            array('controller' => 'fetch',
                  'action' => 'fetch'),
                array(1 => 'fetchParameter')

        $router->addRoute('fetch', $routeFetch);

This entry was posted in PHP and tagged , , , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Why ask?