PSR-15
Slim 4, Mezzio 3 and Yii3 share PSR-7 request conversion. Use PsrRequestHandler directly with any PSR-15 request handler.
composer require 'mini4work/webserver:^1.8' 'psr/http-server-handler:^1' 'nyholm/psr7:^1.8'Read request bodies
The adapter reads input before dispatch and sets the method, request target, query and cookies. HTTP/2 and HTTP/3 use :authority for the URI and Host header. Pseudo-headers are omitted.
Ordinary bodies go to a seekable temporary file in 16 KiB chunks. URL-encoded forms stay in memory up to the lower of the two limits below. Transport limits still apply.
use M4W\WebServer\Adapters\Psr\PsrRequestHandler;
use M4W\WebServer\Http\Form\MultipartOptions;
$handler = new PsrRequestHandler(
$app,
maxBodyBytes: 67_108_864,
multipart: new MultipartOptions(),
maxFormBytes: 262_144,
);Multipart uses separate limits. Read nested fields with getParsedBody() and temporary uploads with getUploadedFiles(). The raw multipart body is empty after parsing.
new MultipartOptions(
maxBodyBytes: 1_048_576,
maxFileBytes: 1_048_576,
maxFieldBytes: 65_536,
maxFieldTotalBytes: 262_144,
maxParts: 128,
maxFiles: 32,
maxHeaderBytes: 8192,
maxHeaders: 32,
);Send a response
Repeated headers such as Set-Cookie stay separate. Reads start at byte zero for seekable streams and at the current position otherwise. Each read must yield data or EOF. Completion, HEAD suppression and cancellation close the stream and release uploads.
Request state
Keep user and session data on the request. Slim and Mezzio middleware must reset mutable services in shared containers. Blocking stream reads occupy the worker. An uncaught exception can rotate the worker.