jasny / router
v1.1.3
2020-01-16 15:40 UTC
Requires
- php: >=5.6.0
- jasny/php-functions: ^2.0|^3.0|^4.0
- psr/http-message: ^1.0
- psr/log: ^1.0
Requires (Dev)
- jasny/php-code-quality: 2.1.*
- dev-master
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-errorpage
- dev-strict-controller-class
- dev-controller-runner-namespace
- dev-determine-route-middleware
- dev-glob-stdclass-routes
- dev-controller-runner-notfound
- dev-middleware-path
- dev-docs
- dev-fix-tests
- dev-router-cleanup
- dev-glob-tests
- dev-runner
This package is auto-updated.
Last update: 2020-01-16 15:41:46 UTC
README
Jasny Router是一个多功能的PSR-7兼容路由器。它将确定路由的方式与路由和执行路由操作解耦。路由器支持双遍历中间件。
安装
Jasny Router包可在包管理器中找到。使用composer进行安装。
composer require jasny/router
基本用法
use Jasny\Router; use Jasny\Router\Routes\Glob as Routes; use Jasny\HttpMessage\ServerRequest; use Jasny\HttpMessage\Response; $routes = new Routes([ '/' => function($request, $response) { $response->getBody()->write('Hello world'); return $response; }, ]); $router = new Router($routes); $router->handle(new ServerRequest()->withGlobalEnvironment(), new Response());
路由
创建Router
时,需要传递一个实现了RoutesInterface
的对象。路由应被视为一组路由集合,能够根据服务器请求选择其中的一个路由。