runtime/psr-17

PSR runtime with support for any PSR-17 implementation

Maintainers

👁 Nyholm

Package info

github.com/php-runtime/psr-17

pkg:composer/runtime/psr-17

Fund package maintenance!

nyholm

Statistics

Installs: 2 768

Dependents: 0

Suggesters: 0

Stars: 3

Open Issues: 1

1.0.0 2025-12-18 07:34 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT d6cea7b28108a6f675a2a03f98f7f78d356d23b7

  • Tobias Nyholm <tobias.nyholm.woop@gmail.com>

This package is auto-updated.

Last update: 2026-06-18 08:41:00 UTC


README

A runtime with support for any PSR-17 compatible implementation.

If you are new to the Symfony Runtime component, read more in the main readme.

Installation

Install this runtime plus a package that provide psr/http-factory-implementation.

composer require runtime/psr-17 slim/psr7

Also update your composer.json with some extra config:

{
 "require": {
 "...": "..."
 },
 "extra": {
 "runtime": {
 "psr17_server_request_factory": "Slim\\Psr7\\Factory\\ServerRequestFactory"
 "psr17_uri_factory": "Slim\\Psr7\\Factory\\UriFactory"
 "psr17_uploaded_file_factory": "Slim\\Psr7\\Factory\\UploadedFileFactory"
 "psr17_stream_factory": "Slim\\Psr7\\Factory\\StreamFactory"
 }
 }
}

Usage

This runtime is discovered automatically. You can force your application to use this runtime by defining the environment variable APP_RUNTIME.

APP_RUNTIME=Runtime\Psr17\Runtime

PSR-7

// public/index.php

use Psr\Http\Message\ServerRequestInterface;
use Any\Psr7;

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function (ServerRequestInterface $request) {
 return new Psr7\Response(200, [], 'PSR-7');
};

PSR-15

// public/index.php

use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Any\Psr7;

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

class Application implements RequestHandlerInterface {
 // ...
 public function handle(ServerRequestInterface $request): ResponseInterface
 {
 return new Psr7\Response(200, [], 'PSR-15');
 }
}

return function (array $context) {
 return new Application($context['APP_ENV'] ?? 'dev');
};