charm / fsrouter-middleware
1.0.3
2022-03-04 12:27 UTC
Requires
- charm/options: ^1.0
- charm/util-composerpath: ^1.0
README
一个将路径转换为文件系统中的文件名的路由器实现。也可以用作PSR-15路由中间件。
字符串hello/world
按照以下近似顺序路由到以下路径之一。目标文件名index.php
、default.php
以及扩展名.php
均可配置。
routes/hello/world/index.php
routes/hello/world/default.php
routes/hello/world.php
routes/_/world/index.php
routes/_/world/default.php
routes/_/world.php
routes/hello/_/index.php
routes/hello/_/default.php
routes/_/_/index.php
routes/_/_/default.php
routes/_/default.php
routes/default.php
注意!此顺序是近似的。从根目录开始解析,优先进入目录。当路由失败时,它将退出目录并查找
创建路由器实例
new FsRouterMiddleware([
'routes_path' => dirname(__DIR__).'/routes'
])