biurad/
http-galaxy
Http Galaxy:HTTP请求、响应和CSP保护的抽象。提供对URL和cookie操作的数据清洗和实用工具。
v0.1.4
2020-06-23 04:13 UTC
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-09-18 01:16:20 UTC
README
The Poakium Http Galaxy
一个设计用于提供PSR-7、PSR-15和PSR-17无缝集成symfony/http-foundation的PHP库,用于您的项目。
📦 安装
本项目需要PHP 7.4或更高版本。推荐通过Composer安装。只需运行
$ composer require biurad/http-galaxy
📍 快速开始
由于symfony/http-foundation库本身就是一个标准,依赖PHP-FIG标准的库难以与之集成。使用此库,您可以安全地使用PHP-FIG标准并获得良好的性能。通过HTTP Galaxy快速构建。
以下是如何使用此库的示例
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();
📓 文档
关于如何使用此库的深入文档可以在docs.biurad.com找到。还建议浏览tests目录中的单元测试。
🙌 赞助者
如果这个库被用在您的项目中,或者您有兴趣支持我们,请考虑捐赠以支持未来的开发。
👥 致谢与认可
- Divine Niiquaye Ibok是该库的作者。
- 所有贡献者都为此项目做出了贡献。
📄 许可证
Poakium HTTP Galaxy完全免费,并按照BSD 3许可证发布。