ajgarlag/psr-http-message-bundle
Composer 安装命令:
composer require ajgarlag/psr-http-message-bundle
包简介
README 文档
README
This bundle provides support for HTTP messages interfaces defined
in PSR-7. It allows to inject instances of Psr\Http\Message\ServerRequestInterface
and to return instances of Psr\Http\Message\ResponseInterface in controllers.
The inital code is borrowed from sensio/framework-extra-bundle which removed support for PSR-7 since version 6.0.
Installation
To install the latest stable version of this component, open a console and execute the following command:
$ composer require ajgarlag/psr-http-message-bundle
Note that autowiring aliases for PSR-17 must be installed. An easy way to provide them is to require nyholm/psr7 :
$ composer require nyholm/psr7
Configuration
If your code depends on old sensio_framework_extra_... services identifiers, you should enable aliasing defining:
ajgarlag_psr_http_message: alias_sensio_framework_extra_services: enabled: true
Usage
Then, PSR-7 messages can be used directly in controllers like in the following code snippet
namespace App\Controller; use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ServerRequestInterface; class DefaultController { public function index(ServerRequestInterface $request, ResponseFactoryInterface $responseFactory) { // Interact with the PSR-7 request $response = $responseFactory->createResponse(); // Interact with the PSR-7 response return $response; } }
Note that internally, Symfony always use Symfony\Component\HttpFoundation\Request
and Symfony\Component\HttpFoundation\Response instances.
Upgrade path from sensio/framework-extra-bundle PSR-7 support
If your code depends on sensio/framework-extra-bundle PSR-7 support, this is the suggested upgrade path:
- Require
sensio/framework-extra-bundle:^5.3. - Require
ajgarlag/psr-http-message-bundle:^1.1, and enable old services aliasing. - Disable PSR-7 support in
sensio_framework_extraconfiguration. - If your code depends on old
sensio_framework_extra.psr7.http_(message|foundation)_factoryservices identifiers, modify service definitions to use theSymfony\Bridge\PsrHttpMessage\Http(Message|Foundation)Interfacealternatives following deprecation messages. - Do you need any other feature provided by
sensio/framework-extra-bundle?:- YES: require
sensio/framework-extra-bundle:^6.0. - NO: remove
sensio/framework-extra-bundle.
- YES: require
License
This component is under the MIT license. See the complete license in the LICENSE file.
Reporting an issue or a feature request
Issues and feature requests are tracked in the Github issue tracker.
Author Information
Developed with ♥ by Antonio J. García Lagar.
If you find this component useful, please add a ★ in the GitHub repository page and/or the Packagist package page.
ajgarlag/psr-http-message-bundle 适用场景与选型建议
ajgarlag/psr-http-message-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 613.86k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2021 年 02 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ajgarlag/psr-http-message-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ajgarlag/psr-http-message-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 613.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 14
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-04