项目作者: biurad

项目描述 :
🪐 A library that provides functionality for http pipelines: psr-7, psr-13, psr-15, psr-17, psr-18, cors, csp and cookies manipulations.
高级语言: PHP
项目地址: git://github.com/biurad/php-http-galaxy.git
创建时间: 2019-12-17T02:01:41Z
项目社区:https://github.com/biurad/php-http-galaxy

开源协议:BSD 3-Clause "New" or "Revised" License

下载




# 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:

  1. $ 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:

  1. use Biurad\Http\Factory\Psr17Factory;
  2. use Biurad\Http\Middlewares\PrepareResponseMiddleware;
  3. use Biurad\Http\Response;
  4. use Laminas\Stratigility\Middleware\CallableMiddlewareDecorator;
  5. use Laminas\Stratigility\MiddlewarePipe;
  6. use Psr\Http\Message\{ResponseInterface, ServerRequestInterface};
  7. use Psr\Http\Server\RequestHandlerInterface;
  8. // Create a PSR-7 Request
  9. $request = Psr17Factory::fromGlobalRequest();
  10. // Create a PSR-15 Request Handler
  11. $dispatcher = new MiddlewarePipe();
  12. $dispatcher->pipe(new PrepareResponseMiddleware());
  13. $dispatcher->pipe(
  14. new CallableMiddlewareDecorator(
  15. function (ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface {
  16. // Apply middleware logic here
  17. return $handler->handle($request);
  18. }
  19. )
  20. );
  21. // A request handler handling application's logic
  22. $handler = new \App\MyRequestHandler();
  23. // Process the request handler and middleware(s)
  24. $response = $dispatcher->process($request, $handler);
  25. \assert($response instanceof Response);
  26. // Send the response to the client from symfony's response object
  27. $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.