furious / router
Router 的 PHP 7.4 实现
1.0.1
2020-07-12 06:24 UTC
Requires
- php: >=7.4
- psr/http-message: ^1.0
Requires (Dev)
- furious/psr7: ^1.3
- phpunit/phpunit: ^5.4
This package is auto-updated.
Last update: 2024-09-12 00:40:53 UTC
README
适用于 PSR-7 请求的简单路由器。PHP 7.4+
安装
composer require furious/router
使用
$routes = new RouteCollection();
// Add route
$routes->get('home', '/path', SomeHandler::class);
$router = new Router($routes);
// '/path'
$router->generate('home');
// Match route
$router->match($psr7Request);
// Add route in router
$router->addRoute(new Route('about', '/about', AboutHandler::class, 'GET'));