thingston/psr17

Implementation of PSR-17 standard for factories that create PSR-7 compliant HTTP objects.

Maintainers

Package info

github.com/thingston/psr17

pkg:composer/thingston/psr17

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-05-12 12:44 UTC

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