conectra / highway
HighWay 是一个通过模式结构化的简单路由引擎
v0.2.1
2017-08-18 10:47 UTC
Requires
- php: ^7.0
- monolog/monolog: ^1.21
- slim/slim: ^3.0
- solis/phpbreaker: ~v1.0
This package is not auto-updated.
Last update: 2024-09-29 04:31:18 UTC
README
HighWay
HighWay 是一个为了从 Slim Framework 3 中抽象路由管理过程而开发的机制
如何安装?
此软件包旨在通过 composer 进行安装
composer require solis/highway
如何使用?
首先需要定义一个模式,表示为应用创建的路线
[
{
"request": {
"uri": "/sample/get/",
"method": "GET",
"controller": {
"class": "Sample\\Classes\\Sample",
"method": "find"
}
},
"middleware": {
"auth"
},
"response": {
"sType": "withJson"
}
}
]
创建 SlimHighWay 类的实例,并使用静态方法 make 将新路线绑定到相应的实例
use HighWay\Wrappers\SlimApp\SlimHighWay;
$routes = json_decode(
file_get_contents('path/to/Route.json'),
true
);
$app = SlimHighWay::make(
$routes
);
$app->run();
SlimHighWay 将根据模式中的现有规格负责创建 Slim Framework 3 所使用的路由实例。