borsch / router
A routing library.
1.3
2020-05-02 03:31 UTC
Requires
- league/uri: 6.2.1
- nikic/fast-route: v1.3.0
- psr/http-message: 1.0.1
- psr/http-server-middleware: 1.0.1
Requires (Dev)
- laminas/laminas-diactoros: 2.2.2
This package is auto-updated.
Last update: 2024-10-29 05:53:28 UTC
README
A simple router implementation inspired by Mezzio.
This package is part of the Borsch Framework.
Installation
Via composer :
composer require borsch/router
Usage
require_once __DIR__.'/vendor/autoload.php'; use Borsch\Router\UriTemplateRouter; $router = new UriTemplateRouter(); $router->get( '/hotels/{hotel}/bookings/{booking}', function (ServerRequestInterface $request, RequestHandlerInterface $handler) { // Laminas\Diactoros\Response or any other PSR-7 implementation. $response = new \Laminas\Diactoros\Response(); $response->getBody()->write('Welcome to the hotel page !'); return $response; }, 'route-name' ); $server_request = \Laminas\Diactoros\ServerRequestFactory::fromGlobals(); $route_result = $router->match($server_request); // $route_result is an instance of RouteResultInterface.
License
The package is licensed under the MIT license. See License File for more information.