zonuexe/simple-routing
Composer 安装命令:
composer require zonuexe/simple-routing
包简介
Simple Web Application Router
关键字:
README 文档
README
Simple routing for WebApp
No magic. No reflection. No complex dependency.
Installation
Composer
composer require zonuexe/simple-routing
References
Routing DSL
// Method Path ReturnValue Param => RegExp extension (format) $routing_map = [ ['GET', '/', 'index' ], ['GET|POST', '/search', 'search' ], ['GET', '/article/:id', 'article', ['id' => '/\A(\d+)\z/'], '?ext' => ['', 'txt']], ['GET', '/info', 'feed' , '?ext' => ['rss', 'rdf', 'xml']], '#404' => 'not_found' // special ]; $router = new \Teto\Routing\Router($routing_map); $action = $router->match($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']); // Shorthand (but, do not use reverse routing) $action = \Teto\Routing\Router::dispatch($routing_map, $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
Reverse routing
// Name Method Path ReturnValue Param => RegExp extension (file format) $routing_map = [ 'root' => ['GET', '/', 'index' ], 'search' => ['GET|POST', '/search', 'search' ], 'article' => ['GET', '/article/:id', 'article', ['id' => '/\A(\d+)\z/'], '?ext' => ['', 'txt']], 'info' => ['GET', '/info', 'feed' , '?ext' => ['rss', 'rdf', 'xml']], '#404' => 'not_found' // special ]; $router = new \Teto\Routing\Router($routing_map); $router->makePath('root'); //=> '/' $router->makePath('search'); //=> '/search' $router->makePath('article', ['id' => 123]); //=> '/article/123' $router->makePath('info', ['?ext' => 'rss']); //=> '/info.rss'
Tips
$re_num_id = '/\A(\d+)\z/'; $re_user_name = '/\A@([a-z]+)\z/'; $routing_map = [ 'root' => ['GET', '/', 'index' ], 'search' => ['GET', '/search', 'search' ], 'article' => ['GET', '/article/:id', 'article', ['id' => $re_num_id], '?ext' => ['', 'txt']], '#404' => 'not_found' // special ];
Related Libraries
You can get these libraries from Packagist.
Copyright
Teto\Routing is licensed under Apache License Version 2.0. See ./LICENSE.
Teto Routing - PHP simple router for WebApp
Copyright (c) 2016 Baguette HQ / USAMI Kenta <tadsan@zonu.me>
Teto Kasane
I love Teto Kasane. (ja: Teto Kasane official site)
r /
__ , --ヽ!-- .、_
! `/::::;::::ヽ l
!二二!::/}::::丿ハニ|
!ニニ.|:/ ノ/ }::::}コ
L二lイ 0´ 0 ,':ノコ
lヽノ/ヘ、 '' ▽_ノイ ソ
ソ´ /}`ス / ̄ ̄ ̄ ̄/
.(_:;つ/ 0401 / カタカタ
 ̄ ̄ ̄ ̄ ̄\/____/
zonuexe/simple-routing 适用场景与选型建议
zonuexe/simple-routing 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14.42k 次下载、GitHub Stars 达 21, 最近一次更新时间为 2015 年 02 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「router」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zonuexe/simple-routing 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zonuexe/simple-routing 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zonuexe/simple-routing 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Router
PMVC App Action Router
Database alias router extension for Nette Framework
PHP Router
A PSR7 / PSR-15 compatible HTTP router.
Simple PHP Router, with prefix groups and filtering
统计信息
- 总下载量: 14.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 21
- 点击次数: 4
- 依赖项目数: 4
- 推荐数: 2
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2015-02-03