h4cc/stack-psr7-bridge
Composer 安装命令:
composer require h4cc/stack-psr7-bridge
包简介
StackPHP Middleware for converting Symfony Http abstractions to PSR-7 and back.
README 文档
README
StackPHP Middleware for using Symfony HttpKernel Applications and PSR-7 Application transparent.
This Middleware tries to make using Symfony HttpKernel Application and PSR-7 as easy as possible.
Wrapped applications can be:
- Any Symfony HttpKernel
- Any Callback expecting
function(RequestInterface $request, ResponseInterface $response, $next = null)
It does not matter what kind of application is wrapped, the bridge will convert incoming requests and outgoing responses accordingly to the used interface.
The implementation this middleware is based on is https://github.com/symfony/psr-http-message-bridge.
Usage
By default, the Symfony HttpFoundation and HttpKernel are used. For PSR-7, the Zend-Diactoros implementation is used. These implementations can be changed if needed.
Wrapping a HttpKernel
<?php $bridge = new Psr7Bridge($yourHttpKernel); // Handling PSR-7 requests $psr7Response = $bridge->__invoke($psr7Request, $psr7Response); // Handling Symfony requests $symfonyResponse = $bridge->_handle($symfonyRequest);
Wrapping a PSR-7 callback
The expected PSR-7 callback format is not yet defined by PHP-FIG and might be subject to change!
<?php $psr7Callback = function(RequestInterface $request, ResponseInterface $response, $next = null) { // Creating a PSR-7 Response here ... }; $bridge = new Psr7Bridge($psr7Callback); // Handling PSR-7 requests $psr7Response = $bridge->__invoke($psr7Request, $psr7Response); // Handling Symfony requests $symfonyResponse = $bridge->_handle($symfonyRequest);
Installation
The recommended way to install stack-psr7-bridge is through Composer:
composer require h4cc/stack-psr7-bridge
Protip: you should browse the h4cc/stack-psr7-bridge
page to choose a stable version to use, avoid the @stable meta constraint.
License
h4cc/stack-psr7-bridge is released under the MIT License. See the bundled LICENSE file for details.
h4cc/stack-psr7-bridge 适用场景与选型建议
h4cc/stack-psr7-bridge 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 99 次下载、GitHub Stars 达 15, 最近一次更新时间为 2015 年 06 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 h4cc/stack-psr7-bridge 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 h4cc/stack-psr7-bridge 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 99
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 15
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-05