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月前
|
网络协议
【HCIP】09.路由引入
【HCIP】09.路由引入
55 0
|
3月前
|
JavaScript 前端开发 API
探索应用程序的指路明灯:Route 和 Router 入门指南(上)
探索应用程序的指路明灯:Route 和 Router 入门指南(上)
探索应用程序的指路明灯:Route 和 Router 入门指南(上)
|
3月前
|
前端开发 JavaScript UED
探索应用程序的指路明灯:Route 和 Router 入门指南(下)
探索应用程序的指路明灯:Route 和 Router 入门指南(下)
探索应用程序的指路明灯:Route 和 Router 入门指南(下)
|
PHP
PHP - Laravel 路由参数
PHP - Laravel 路由参数
54 0
|
8月前
|
小程序
laravel8(二)配置自定义路由文件
关于laravel5添加自定义路由文件,请移步《laravel5.8(十五)新增自定义路由文件》 这里大概记录一下laravel8添加自定义路由文件的过程: 持续创作,加速成长!这是我参与「掘金日新计划 · 10 月更文挑战」的第11天,点击查看活动详情 1:首先在routes目录下创建你要添加的自定义路由文件 我这里直接复制的web.php。 2:修改app/Providers目录下RouteServiceProvider.php文件 我这里也是直接复制web部分的代码改的名字 3:修改app/Http目录下Kernel.php文件 我这里还是直接复制web部分的代码改的名
63 1
|
8月前
|
小程序 中间件 API
laravel5.8(五)基本路由配置
在使用laravel之前我一直在使用thinkphp还有yii框架,这两个框架也有路由这一说,但是都没有用过。 Laravel的路由功能其实还是挺全的,也很优雅~ 下面来说正题: 1:路由的基本介绍 Laravel框架默认为我们提供了两个路由文件,在根目录下的routes目录下有web.php以及api.php。这些文件通过框架自动加载,相应逻辑位于 app/Providers/RouteServiceProvider 类。routes/web.php 文件定义了 Web 界面的路由,这些路由被分配到了 web 中间件组,从而可以使用 Session 和 CSRF 保护等功能。routes/a
64 0
|
PHP
PHP - Laravel 路由分组 - 路由前缀
PHP - Laravel 路由分组 - 路由前缀
64 0
|
PHP
PHP Laravel 路由(接口)重定向
PHP Laravel 路由(接口)重定向
60 0
|
缓存 中间件 PHP
ThinkPHP路由源码解析(一)(1)
ThinkPHP路由源码解析(一)
194 0
ThinkPHP路由源码解析(一)(1)
|
PHP 容器
ThinkPHP路由源码解析(一)(5)
ThinkPHP路由源码解析(一)
138 0
ThinkPHP路由源码解析(一)(5)