biurad / http-galaxy
Http Galaxy: abstraction for HTTP request, response, and csp protection. Provides careful data sanitization and utility for URL and cookies manipulation.
Fund package maintenance!
Patreon
biurad.com/sponsor
Requires
- php: ^7.2
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^6.5
- laminas/laminas-httphandlerrunner: ^1.1
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: ~7.5
Suggests
- biurad/biurad-http-cache: A fully-featured reverse proxy (i.e. gateway cache) written in PHP. Implementation of Symfony HTTP Cache
- biurad/biurad-sessions: A session object and several utilities that you can use to store information about the user between requests.
This package is auto-updated.
Last update: 2024-12-18 01:46:49 UTC
README
The Poakium Http Galaxy
A PHP library that designed to provide PSR-7, PSR-15 and PSR-17 seamless integration with symfony/http-foundation for your projects.
📦 Installation
This project requires PHP 7.4 or higher. The recommended way to install, is via Composer. Simply run:
$ composer require biurad/http-galaxy
📍 Quick Start
Since symfony/http-foundation library is a standard on it's own, libraries which relies on PHP-FIG standard makes it difficult to integrate with. With this library you can safely use PHP-FIG standards with good performance. build quickly using HTTP Galaxy.
Here is an example of how to use the library:
use Biurad\Http\Factory\Psr17Factory; use Biurad\Http\Middlewares\PrepareResponseMiddleware; use Biurad\Http\Response; use Laminas\Stratigility\Middleware\CallableMiddlewareDecorator; use Laminas\Stratigility\MiddlewarePipe; use Psr\Http\Message\{ResponseInterface, ServerRequestInterface}; use Psr\Http\Server\RequestHandlerInterface; // Create a PSR-7 Request $request = Psr17Factory::fromGlobalRequest(); // Create a PSR-15 Request Handler $dispatcher = new MiddlewarePipe(); $dispatcher->pipe(new PrepareResponseMiddleware()); $dispatcher->pipe( new CallableMiddlewareDecorator( function (ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { // Apply middleware logic here return $handler->handle($request); } ) ); // A request handler handling application's logic $handler = new \App\MyRequestHandler(); // Process the request handler and middleware(s) $response = $dispatcher->process($request, $handler); \assert($response instanceof Response); // Send the response to the client from symfony's response object $response->getResponse()->send();
📓 Documentation
In-depth documentation on how to use this library can be found at docs.biurad.com. It is also recommended to browse through unit tests in the tests directory.
🙌 Sponsors
If this library made it into your project, or you interested in supporting us, please consider donating to support future development.
👥 Credits & Acknowledgements
- Divine Niiquaye Ibok is the author this library.
- All Contributors who contributed to this project.
📄 License
Poakium HTTP Galaxy is completely free and released under the BSD 3 License.