Sunday, August 15, 2010

Zend Router application.ini

if you want http://domain.com/user to be mapped to http://domain.com/index/index/username/kranthi
use this in your application.ini file
resources.router.routes.route_id.route = "/user/:username/*"
resources.router.routes.route_id.defaults.controller = "index"
resources.router.routes.route_id.defaults.action = "index"
resources.router.routes.route_id.defaults.username = "kranthi"

this code executes before transferring the control to the controller

in zend docs it is mentioned
$router = $ctrl->getRouter();
here $ctrl is an instance of Zend_Controller_Front and should be declared before running your bootstrap file in your index.php (single point of entry) file
$ctrl  = Zend_Controller_Front::getInstance();
$router = $ctrl->getRouter();
.
.
.
$application->bootstrap()
            ->run();

No comments:

Post a Comment