有些php框架通过path info 进行路由

nginx 需指定path info 的配置

yaf 通过$_SERVER['REQUEST_URI']路由

http://yaf_demo.com/user/user/show/userId/100

$params = $this->getRequest()->getParams();

默认的路由这上面这样

yaf支持5种路由形式

E:\code\yaf_demo\application\Bootstrap.php   _initRoute  这里设置路由

$router = $dispatcher::getInstance()->getRouter();

$route = new Yaf\Route\Simple('m','c','a');

$router->addRoute('simple', $route);

http://yaf_demo.com/?m=user&c=user&a=show

也可以通过配置文件添加路由

[routes]

routes.simple.type = "simple"

routes.simple.module = "m"

routes.simple.controller = "c"

routes.simple.action = "a"

[develop : common : redis : routes](记得当前环境加上routes)

E:\code\yaf_demo\application\Bootstrap.php   _initRoute  加上下面两句

$router = $dispatcher::getInstance()->getRouter();

$router->addConfig(Yaf\Registry::get('config')->routes);


http://yaf_demo.com/1001

routes.user.type = "regex"

routes.user.match = "#^/([0-9]+)[\/]?$#"

routes.user.route.module = "User"

routes.user.route.controller = "User"

routes.user.route.action = "show"

routes.user.map.1 = userId


http://yaf_demo.com/list/12.html

routes.list.type = "regex"

routes.list.match = "#^/list/([0-9]+).html?$#"

routes.list.route.module = "Index"

routes.list.route.controller = "List"

routes.list.route.action = "index"

routes.list.map.1 = catId


http://yaf_demo.com/list/sdge-1111.html

routes.list.type = "regex"

routes.list.match = "#^/list/([a-z]+)[-]?([1-9]+)?.html?$#"

routes.list.route.module = "Index"

routes.list.route.controller = "List"

routes.list.route.action = "index"

routes.list.map.1 = catName

routes.list.map.2 = page