Zend Router simple extension through simple regex


/ Published in: PHP
Save to your folder(s)

You have to add this code in your Bootstrap


Copy this code and paste it in your HTML
  1. /**
  2. * Add this in your bootstrap
  3. */
  4. protected function _initRoutes() {
  5.  
  6. $ctrl = Zend_Controller_Front::getInstance();
  7. $router = $ctrl->getRouter();
  8. //match every call on http://ZEND_ROOT/aZ2s-Ty9
  9. $route = new Zend_Controller_Router_Route_Regex('([a-zA-Z0-9]+\-[a-zA-Z0-9]+)',
  10. //dispatch this to the VController
  11. 'controller' => 'v',
  12. // iAction()
  13. 'action' => 'i'
  14. ),
  15. //send the captured value has the "e" parameters of the request
  16. 1 => 'e'
  17. )
  18. );
  19.  
  20. //give a name to your route and add it to the default router
  21. $router->addRoute('view',$route);
  22. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.