Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/debuss/borsch-router
A simple router implementation inspired by Mezzio.
https://github.com/debuss/borsch-router
Last synced: about 2 months ago
JSON representation
A simple router implementation inspired by Mezzio.
- Host: GitHub
- URL: https://github.com/debuss/borsch-router
- Owner: debuss
- License: mit
- Created: 2020-03-26T05:41:28.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-02T03:32:06.000Z (over 4 years ago)
- Last Synced: 2024-04-05T02:01:44.037Z (10 months ago)
- Language: PHP
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Borsch - Router
A simple router implementation inspired by [Mezzio](https://docs.mezzio.dev/mezzio/).
This package is part of the Borsch Framework.
## Installation
Via [composer](https://getcomposer.org/) :
`composer require borsch/router`
## Usage
```php
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](https://github.com/debuss/borsch-router/blob/master/LICENSE.md) for more information.