https://github.com/pollen-solutions/routing
Pollen Solutions - Routing Component - HTTP request mapping and HTTP response resolution
https://github.com/pollen-solutions/routing
Last synced: 4 months ago
JSON representation
Pollen Solutions - Routing Component - HTTP request mapping and HTTP response resolution
- Host: GitHub
- URL: https://github.com/pollen-solutions/routing
- Owner: pollen-solutions
- License: mit
- Created: 2021-07-09T13:04:20.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-13T09:36:30.000Z (over 2 years ago)
- Last Synced: 2025-02-14T22:39:19.851Z (5 months ago)
- Language: PHP
- Size: 75.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Routing Component
[](https://packagist.org/packages/pollen-solutions/routing)
[](LICENSE.md)
[](https://www.php.net/supported-versions.php)Pollen Solutions **Routing** Component provide a layer of HTTP request mapping and HTTP response resolution.
## Installation
```bash
composer require pollen-solutions/routing
```## Basic Usage
```php
map('GET', '/', static function (): ResponseInterface {
return new Response('Hello, World!
');
});$router->map('GET', '/phpinfo', static function () {
ob_start();
phpinfo();
return new Response(ob_get_clean());
});// Setting Handle Request (optional)
$psrRequest = Request::createFromGlobals()->psr();// Map a Fallback Route (optional)
$router->setFallback(function () {
return new Response('404 - Page not found !
', 404);
});// Catch HTTP Response
$response = $router->handle($psrRequest);// Send the response to the browser
$router->send($response);// Trigger the terminate event
$router->terminate($psrRequest, $response);
```