yaf -- 路由访问/配置

yaf

在Bootstrap.php文件下注册路由协议
public function _initRoute(Yaf_Dispatcher $dispatcher) {
        $router = $dispatcher->getRouter();
        $router->addConfig(Yaf_Registry::get("config")->routes);
    }
在application.ini 加入自己定义的路由规则

;application.modules = "Test"

routes.route_name1.type="regex"
routes.route_name1.match="#^list/([^/]*)/([^/]*)#"
routes.route_name1.route.controller=Test
routes.route_name1.route.action=test
routes.route_name1.map.1=name
routes.route_name1.map.2=value

routes.regex.type="regex"
routes.regex.match="#^/list/([^/]*)/([^/]*)#"
routes.regex.route.controller=Index
routes.regex.route.action=action
routes.regex.map.1=name
routes.regex.map.2=value
;添加一个名为simple的路由协议
routes.simple.type="simple"
routes.simple.controller=c
routes.simple.module=m
routes.simple.action=a
;添加一个名为supervar的路由协议
routes.supervar.type="supervar"
routes.supervar.varname=r

;[product : common]
;product节是Yaf默认关心的节, 添加一个名为rewrite的路由协议
;routes.rewrite.type="rewrite"
;routes.rewrite.match="/product/:name/:value"
在controllers下新建控制器controller[index] action[test1] 

public function test1Action(){
         $test1 =  ['a','b','c','d','d'];
         $this->getView()->assign("content", $test1);//默认找的view 下的index目录test1.phtml文件
       //$this->getView()->display('index/test1.phtml'); 

    }

通过url 访问
www.xxx.com/index.php/index/index/test1
www.xxx.com/index.php?r=index/index/test1
www.xxx.com/index.php?m=index&c=index&a=test1

https://my.oschina.net/20130614/blog/158095
http://www.php1.cn/Content/Yaf_LingJiChuXueXiZongJie_8-Yaf_ZhongDeLuYouHeLuYouXieYi.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值