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,如需转载请自行联系原作者
相关文章
|
存储 数据采集 监控
分钟级定位 IO 瓶颈:多租户云环境下的智能诊断
阿里云推出IO一键诊断功能,智能识别IO延迟高、流量异常等问题,通过动态阈值与多指标关联分析,实现秒级异常发现与根因定位,提升云环境存储性能问题解决效率。
436 12
分钟级定位 IO 瓶颈:多租户云环境下的智能诊断
|
10月前
|
人工智能 自然语言处理 运维
不懂代码照样造网站,老金15万字Claude Code+OpenClaw教程免费开源
春节期间,零代码基础的老金仅凭语音指令,用Claude Code(武器)和OpenClaw(助理)协同打造了全功能网站aiking.dev。现将两套工具中文教程合并升级为《Claude-Code-x-OpenClaw-Guide-Zh》,10万字免费开源,覆盖从造轮子到调度千军万马的完整AI编程路径。
|
SQL 前端开发 关系型数据库
|
Shell
如何在shell下面实现a+b
如何在shell下面实现a+b
206 0
|
Java Scala
转:Java 下一代: 混入和特征
Java 下一代: 混入和特征 来自http://www.ibm.com/developerworks/cn/java/j-jn8/index.html   ======================================转载正文 Java 语言的开发人员精通 C++ 和其他语言,包括多继承(multiple inheritance),使得类可以继承自任意数量的父类。
1027 0
|
2天前
|
监控 网络协议 算法
2026年起SSL证书有效期逐年缩短:企业如何避免“续期风暴”!
SSL证书有效期将从2026年起分三阶段逐步缩短至47天,人工续期难以为继。阿里云“WoSign SSL证书+自动化服务”,支持域名监控、自动托管、云产品/服务器一键部署及智能提醒,助力企业高效应对高频续期挑战。
8072 2
|
11天前
|
域名解析 人工智能 Linux
|
21天前
|
Linux Go 开发工具
手机上跑 DeepSeek 智能体:开源安卓客户端 DSH Go 安装与使用指南
DSH Go 是一款开源安卓客户端,将 DeepSeek Harness 智能体引擎装进手机:免 Root、免 Termux,一键安装即用;支持本机运行(内置 Ubuntu+Node.js)或远程接管电脑会话;具备插话打断、过程折叠、屏幕操控、端到端加密分享等特色功能,真正实现智能体“口袋化”。
18727 64
|
19天前
|
人工智能
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
进不去 Antigravity 或 Gemini,提示所在地区不可用?三步查清 Google 账号关联地区、官方更正表单理由选法与改区注意事项。
10118 13
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置