yaf 路由

有些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




本文转自 skinglzw 51CTO博客,原文链接:http://blog.51cto.com/skinglzw/1958474,如需转载请自行联系原作者
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值