Skip to content

πŸͺ A library that provides functionality for http pipelines: psr-7, psr-13, psr-15, psr-17, Cors, CSP, session and cookies manipulations.

License

Notifications You must be signed in to change notification settings

biurad/php-http-galaxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1d66554 Β· Aug 21, 2023
Sep 27, 2020
Apr 18, 2022
Aug 22, 2020
Aug 22, 2020
Jul 24, 2021
Sep 27, 2020
Jun 29, 2020
Dec 17, 2019
Aug 21, 2023
Jan 26, 2022
Aug 22, 2020
Aug 22, 2020
Sep 28, 2020

Repository files navigation

The Poakium Http Galaxy

Latest Version Workflow Status Software License Maintenance Status


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

πŸ“„ License

Poakium HTTP Galaxy is completely free and released under the BSD 3 License.