I m new to Zend framework and using framework 2.0. I need certain clarification on routing in PHP Zend framework. 1) What is the role of Bootstrap.php in routing. 2) How we can user index.php for routing. 3) What code needs to be written to achieve custom routing.
Also, i have written certain code, but not getting desired output.
Bootstrap.php:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initRouter() { $frontController = Zend_Controller_Front::getInstance(); $router = $frontController->getRouter(); $route = new Zend_Controller_Router_Route(':userid', array('controller' => 'user', 'action'=> 'index', 'userid'=>null)); $router->addRoute('default', $route); } } index.php
error_reporting(E_ALL); ini_set('display_errors', 1); ini_set('display_errors', true); //Define Base Url define("BASEURL","http://".$_SERVER['SERVER_NAME']."/sampleapp/public/"); // directory setup and class loading set_include_path('.' . PATH_SEPARATOR . 'library/' . PATH_SEPARATOR . 'application/models' . PATH_SEPARATOR . 'application/config' . PATH_SEPARATOR . get_include_path() ); include ('Zend/Loader/Autoloader.php'); $loader = Zend_Loader_Autoloader::getInstance(); // setup controller $frontController = Zend_Controller_Front::getInstance(); $frontController->throwExceptions(true); $frontController->setControllerDirectory('application/controllers'); // run! $frontController->dispatch(); I'm trying to get route values, like my url is:
localhost:8080/sampleapp/user/index/1. How should i get 1 from route. here 1 is userid.