thingston / psr17
Implementation of PSR-17 standard for factories that create PSR-7 compliant HTTP objects.
1.0.0
2026-05-12 12:44 UTC
Requires
- php: >=8.5
- psr/http-factory: ^1.1
- thingston/psr7: ^1.0
Requires (Dev)
- ext-xdebug: *
- friendsofphp/php-cs-fixer: ^3.89
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.1
Provides
This package is auto-updated.
Last update: 2026-05-12 13:11:01 UTC
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