Here's an example:
1. Define your regex route in Bootstrap
Put this code in application/Bootstrap.php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
// other _initXXX
protected function _initRoutes()
{
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
// Add a test regex route
$router->addRoute('article',
new Zend_Controller_Router_Route_Regex
(
"article(?:/(\d+))?",
array(
'controller'=>'article',
'action'=>'view',
1=>123, //set a default value, when url is "http://host/article/"
),
array(
1=>'id' // use 'id' instead of 1
),
"article/%d" // reverse to url , ie $view->url(array('id'=>233),'article',true)
)
);
}
}
2. Create controller and action
$ zf.sh create controller article 1 $ zf.sh create action view Article 1
That's all.
Reference: Programmer's Reference Guide : Zend_Controller : Zend_Controller_Router_Route_RegexDate: 2012-01-03 04:01:20 and last modified: 2012-01-14 22:53:07
Recent entries:
- Emacs rainbow mode
- Squirm a url rewriter for squid
- How to use rsync for transferring files over ssh
- Vide: GRE tunnel
- Video: how to install freebsd
- Video: Install zend framework
- Video: Install Window7 from network
- Install Window7 from a PXE Boot server (Linux/FreeBSD)
- Create GRE tunnel with FreeBSD8
- What's cooking for FreeBSD 9