datapp/router
Composer 安装命令:
composer require datapp/router
包简介
simple PSR-7 regular expression router
README 文档
README
this router library uses regular expression for routing and is compatible to the PHP Standards Recommendations 7 (HTTP Message Interface), 15 (HTTP Handlers) and 17 (HTTP Factories).
Installation
composer require datapp/router
Usage
<?php
require 'vendor/autoload.php';
$router = new Router(new Dispatcher());
// route without middlewares
$router->addRoute(Route::create('GET', '/^(help)$/', new Help($responseFactory, $streamFactory)));
// route with middlewares
$router->addRoute(Route::create('POST', '/^(login)$/', new Login($responseFactory, $streamFactory))
->withMiddleware(new SessionMiddleware(), new AuthMiddleware()));
// using variables (named groups) in regex
$router->addRoute(Route::create('GET', '/^(user)\/(?<id>[\d]+)$/', new UserShow($responseFactory, $streamFactory))
->withMiddleware(new SessionMiddleware(), new AuthMiddleware()));
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-04