Router 的作用就很像 URL rewrite,依不同的 URL 去指向不同的檔案。
Start
Router 可以打在 Bootstrap.php 裡:
function _initRoutes() {
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
// Do something
}Default Routes
// Assuming the following:
$front->setControllerDirectory(
array(
'default' => '/path/to/default/controllers',
'news' => '/path/to/news/controllers',
'blog' => '/path/to/blog/controllers'
)
);結果:
Module only:
http://example/news
module == news
Invalid module maps to controller name:
http://example/foo
controller == foo
Module + controller:
http://example/blog/archive
module == blog
controller == archive
Module + controller + action:
http://example/blog/archive/list
module == blog
controller == archive
action == list
Module + controller + action + params:
http://example/blog/archive/list/sort/alpha/date/desc
module == blog
controller == archive
action == list
sort == alpha
date == desc