jlanger / router
v3.2.1
2020-10-19 09:25 UTC
Requires
- php: >=7.4
- ext-json: *
- jlanger/di: ^2
Requires (Dev)
- phpstan/phpstan: ^0.12.50
- squizlabs/php_codesniffer: ^3.4
README
本项目实现了一个基于php的非常简单的路由器。
配置如下
{
"/homepage": {
"GET": "homepage.php"
},
"/other_page": {
"*": "other_page.php"
}
}
这将允许在/homepage
上仅使用get方法,并在/other-page
上使用所有方法。
配置中的所有路径都必须相对于使用说明部分中提到的索引文档。
使用方法
<?php
include 'vendor/autoload.php';
use JLanger\Router\Router;
use JLanger\Router\JsonRouteStorage;
(new Router(new JsonRouteStorage('config_file.json')))->doRouting($_SERVER);