Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 6 days 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 (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-13T09:36:30.000Z (almost 2 years ago)
- Last Synced: 2024-10-14T14:48:36.952Z (about 1 month 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
[![Latest Stable Version](https://img.shields.io/packagist/v/pollen-solutions/routing.svg?style=for-the-badge)](https://packagist.org/packages/pollen-solutions/routing)
[![MIT Licensed](https://img.shields.io/badge/license-MIT-green?style=for-the-badge)](LICENSE.md)
[![PHP Supported Versions](https://img.shields.io/badge/PHP->=7.4-8892BF?style=for-the-badge&logo=php)](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);
```