Home > centOS, Fedora 12, PHP, Unix/Linux, Zend > Zend router Zend route

Zend router Zend route

How to zend route?

1. application/Bootstrap.php > initialize

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

	/**
	 * @Step 1
	 * 
	 * 
	 */
    public function _initRoutes()
    {

		/**
		 * @Step 2
		 * if not, i have blank view/action.
		 * 
		 */    	
    	echo '[important] - did i got initialized? yes Bootstrap.php > public function _initRoutes(){  }';	
        $front = Zend_Controller_Front::getInstance();
	    $router = $front->getRouter();

		/**
		 * @Step 3
		 * 
		 */
        $route = new Zend_Controller_Router_Route(
          /**
           * @Search input url
           *  
           * url: http://localhost/myzf/public/add/--------anything-----that----sucks-----
           * or   http://localhost/add/.....anything....that----sucks..
           * 
           */
          'add/:add:',

          array(
          	/**
          	 * @Route TO?:
          	 * 
          	 * a. application/controllers/IndexController.php 
          	 */
              'controller' => 'index',

			/**
			 * @Execute WHAT?:
			 * 
			 * a. application/controllers/IndexController.php
			 * b. public function addAction(){ -- run mee -- }
			 * 
			 */	
              'action'     => 'add'

          )
        );

        $router->addRoute('add', $route);

    }
    	
}



2. Visit WRONG/ERROR to create



3. Visit correct url



Done.
Advertisements
Categories: centOS, Fedora 12, PHP, Unix/Linux, Zend
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: