Comments (2)
这个我在设计之初就思考过,而且改动过多次,最初是支持你说的无限路由的,后来我修改成了现在的样子。
原因:
路由歧义,如:api/index, 到底是 api 控制器的 index 方法,还是 api/index 控制器省略了 index 方法没有写,这个在每一级路由都有这个问题,当然这个问题当时我解决了,就像其他 mvc 框架样,按优先级遍历判断文件,但是极大的降低了性能,且路由实现代码非常繁琐,做为一个轻量级框架,我觉得这个无法忍受,然后我根据实际场景分析,现有的项目通常路由大部分都只有两级+3级,因为过长的路由并不友好,而现有 mix 设计的路由,每增加一级路由只需定义一个通用路由即可,也就是说通常一个项目也就只需几条路由即可完成,已经在性能与实用做到了非常好的平衡了。
回到你的问题:
你需要规划简化你的路由,层级不应该太多,当然你如果觉得合适,每一级定义一个通用路由即可,也不费多少时间,但带来的是 N 倍于其他框架的路由性能。
from mix.
在 v1.1.1 增加了如下通配符多级路由配置的支持:
// 路由规则
'rules' => [
// 一级路由
':controller/:action' => [':controller', ':action', 'middleware' => ['Before']],
// 二级路由
':second/:controller/:action' => [':second/:controller', ':action', 'middleware' => ['Before']],
// 三级路由
':third/:second/:controller/:action' => [':third/:second/:controller', ':action', 'middleware' => ['Before']],
],
from mix.
Related Issues (20)
- Redis-subscribe 支持 prefix 否? HOT 1
- 没有对mysql保留关键字做反引号处理 HOT 1
- 2.2版本 UDP服务器会重复执行处理接收到的数据 HOT 2
- 官网无法访问 HOT 2
- 数据量较多时,json_decode可能会失败 HOT 7
- PDO执行使用问号占位符的原生SQL报错 HOT 2
- 建议项目遵从语义化版本来维护版本号 HOT 1
- PHP用ip curl post请求 会卡1秒 HOT 5
- 新版本性能严重下降 HOT 6
- table方法传入表名order报错 HOT 1
- 验证器场景设置optional未生效 HOT 3
- Coroutine中同时使用Channel和Database pool导致出错 HOT 5
- mix-skeleton使用context()->get('guzzle') 报错 HOT 1
- php8RC3-swoole4.5.6 运行出错 HOT 1
- or and 查找抛出异常 HOT 1
- Upgrade to Zipkin 2.0 HOT 1
- log组件报错 HOT 1
- 推送模式卡死 HOT 1
- 如何正确的提交 PR
- V3 启动事务后 lastInsertId 值不正确 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mix.