Studyon Minte9.com
ZF 1.0




Config



Zend_Controller_Router_Rewrite is the standard framework router. 
Routing is the process of taking a URI endpoint (that part of the URI which comes after the base URL) 
and decomposing it into parameters to determine which module, controller, and action of that controller 
should receive the request. 


.htaccess
--------------------------
RewriteEngine on
RewriteRule !.(js|ico|gif|jpg|png|css|html)$ index.php


index.php
------------------------------
$config = new Zend_Config_Ini('path/to/route/config/file', 'production');
$frontController->getRouter()->addConfig($config, 'routes');


Application/config/routes.ini
------------------------------
[production]
;HOMEPAGE
routes.homepage.route = ""
routes.homepage.defaults.module = "default"
routes.homepage.defaults.controller = "frontend"
routes.homepage.defaults.action = "index"
;TEST
routes.test.route = "test/:page"
routes.test.defaults.module = "default"
routes.test.defaults.controller = "frontend"
routes.test.defaults.action = "test"
routes.test.defaults.page = 1

; chain
routes.service_root.chains.list_dealer_details.type = "Zend_Controller_Router_Route_Regex"
routes.service_root.chains.list_dealer_details.route = "([0-9a-z-]+)_([0-9]+)"
routes.service_root.chains.list_dealer_details.defaults.module = "dealers"
routes.service_root.chains.list_dealer_details.defaults.controller = "frontend"
routes.service_root.chains.list_dealer_details.defaults.action = "details"
routes.service_root.chains.list_dealer_details.defaults.type = 1
routes.service_root.chains.list_dealer_details.map.1 = "slug_dealer"
routes.service_root.chains.list_dealer_details.map.2 = "id_dealer"
routes.service_root.chains.list_dealer_details.reverse = "%s_%d"


Application/modules/default/controllers/FrontendController.php
-----------------------------------------------------------------
<?php
class FrontendController extends Zend_Controller_Action {

	public function init() {
		$this->initView ();
		Zend_Layout::getMvcInstance()->setLayout("frontend");
	}

	public function indexAction() {
		$this->view->message = "Hello world";
	}

	public function testAction() {
		$params = $this->getRequest()->getParams();
		$this->view->message = "Page: " . $params['page'];
	}
}


Application/modules/default/views/scripts/frontend/test.phtml
--------------------------------------------------------------
<?php 
echo $this->message;
// Display:
	1) http://zfsite/test - display (Page: 1)
	2) http://zfsite/test/2 - display (Page: 2)


http://www.vayanis.com/2009/03/20/intro-to-zend-framework-routing/
http://framework.zend.com/manual/en/zend.controller.router.html