thingston/psr17
最新稳定版本:1.0.0
Composer 安装命令:
composer require thingston/psr17
包简介
Implementation of PSR-17 standard for factories that create PSR-7 compliant HTTP objects.
README 文档
README
PSR-17 factory implementations for creating PSR-7 HTTP messages with thingston/psr7.
Requirements
- PHP >= 8.5
- Composer
Installation
composer require thingston/psr17
Usage
Instantiate the factory you need and create PSR-7 objects through the PSR-17 interfaces.
<?php declare(strict_types=1); use Thingston\Psr17\RequestFactory; use Thingston\Psr17\ResponseFactory; use Thingston\Psr17\ServerRequestFactory; use Thingston\Psr17\StreamFactory; use Thingston\Psr17\UploadedFileFactory; use Thingston\Psr17\UriFactory; $requestFactory = new RequestFactory(); $responseFactory = new ResponseFactory(); $serverRequestFactory = new ServerRequestFactory(); $streamFactory = new StreamFactory(); $uploadedFileFactory = new UploadedFileFactory(); $uriFactory = new UriFactory(); $request = $requestFactory->createRequest('POST', 'https://example.com/articles'); $response = $responseFactory->createResponse(201); $serverRequest = $serverRequestFactory->createServerRequest( 'GET', 'https://example.com/search?q=psr', ['HTTPS' => 'on'], ); $stream = $streamFactory->createStream('payload'); $uploadedFile = $uploadedFileFactory->createUploadedFile( $streamFactory->createStream('file contents'), null, UPLOAD_ERR_OK, 'example.txt', 'text/plain', ); $uri = $uriFactory->createUri('https://example.com/path?foo=bar');
Available factories
| Factory | Creates |
|---|---|
RequestFactory |
client requests |
ResponseFactory |
responses |
ServerRequestFactory |
server requests, including query and server params |
StreamFactory |
streams from strings, files, or resources |
UploadedFileFactory |
uploaded files |
UriFactory |
URIs |
Testing
composer test
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-12