alexpts/mutable-psr7
Composer 安装命令:
composer require alexpts/mutable-psr7
包简介
A fast PHP7 implementation of PSR-7
README 文档
README
Mutable
The package is based on https://github.com/Nyholm/psr7/. The package is mutable. If you need immutable implementation please to see nyholm/psr7.
A super lightweight PSR-7 implementation. Very strict and very fast.
Installation
composer require alexpts/mutable-psr7
If you are using Symfony Flex then you get all message factories registered as services.
Usage
The PSR-7 objects do not contain any other public methods than those defined in the PSR-7 specification.
Create objects
Use the PSR-17 factory to create requests, streams, URIs etc.
$psr17Factory = new \PTS\Psr7\Factory\Psr17Factory(); $request = $psr17Factory->createRequest('GET', 'http://some.com'); $stream = $psr17Factory->createStream('foobar');
Sending a request
With HTTPlug or any other PSR-18 (HTTP client) you may send requests like:
composer require kriswallsmith/buzz
$psr17Factory = new \PTS\Psr7\Factory\Psr17Factory(); $psr18Client = new \Buzz\Client\Curl($psr17Factory); $request = $psr17Factory->createRequest('GET', 'http://some.com'); $response = $psr18Client->sendRequest($request);
Create server requests
The nyholm/psr7-server package can be used
to create server requests from PHP superglobals.
composer require nyholm/psr7-server
$psr17Factory = new \PTS\Psr7\Factory\Psr17Factory(); $creator = new \Nyholm\Psr7Server\ServerRequestCreator( $psr17Factory, // ServerRequestFactory $psr17Factory, // UriFactory $psr17Factory, // UploadedFileFactory $psr17Factory // StreamFactory ); $serverRequest = $creator->fromGlobals();
Emitting a response
composer require laminas/laminas-httphandlerrunner
$psr17Factory = new \PTS\Psr7\Factory\Psr17Factory(); $responseBody = $psr17Factory->createStream('Hello world'); $response = $psr17Factory->createResponse(200)->withBody($responseBody); (new \Laminas\HttpHandlerRunner\Emitter\SapiEmitter())->emit($response);
Benchmark Tests
composer bench
alexpts/mutable-psr7 适用场景与选型建议
alexpts/mutable-psr7 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 633 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「psr-7」 「mutable」 「psr-17」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 alexpts/mutable-psr7 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alexpts/mutable-psr7 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 alexpts/mutable-psr7 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Model of a web-based resource
Simple PHP Library for RESTful APIs
Multipart PSR-7 stream factories based on PSR-17 factories.
Interfaces for web resource models and services to retrieve and create them
PSR-7 (HttpMessage) & PSR-17 (HttpFactory) Implementations
Interface for a factory to create Psr\Http\Message\StreamInterface objects
统计信息
- 总下载量: 633
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 5
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-09