默认路由
Yaf_Router预设了一个默认路由,它将以controller/action的形式匹配URIs。此外,一个module的名字可以被指定为第一路径元素,允许URIs设置为module/controller/action的形式。最后,它也会匹配一些URI中额外附加的参数,默认形式是controller/action/var1/value1/var2/value2。Note:
Module的名字必须要定义在配置中,就application.module="Index,Foo,Bar"而言,在这种情况下,仅仅index, foo 和 bar能被考虑作为为一个module的名称。如果没有在配置文件中定义,那么Yaf使用默认的module名字“Index”。
如何匹配这些路由的一些例子:
Example #5 Yaf_Route_Static(default
route)example
// Assuming the following configure:
$conf = array(
"application" => array(
"modules" => "Index,Blog",
),
);
Controller only:
http://example/news
controller == news
Action only(when defined yaf.action_prefer=1 in php.ini)
action == 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