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=test1https://my.oschina.net/20130614/blog/158095 http://www.php1.cn/Content/Yaf_LingJiChuXueXiZongJie_8-Yaf_ZhongDeLuYouHeLuYouXieYi.html