laminas-diactoros
A pure PHP implementation of the PSR-7 HTTP message and PSR-17 HTTP factory interfaces.
Repository Health
Technical Analysis
laminas-diactoros (named for the Greek epithet meaning ‘the messenger’) is a foundational PHP package that implements the PSR-7 HTTP message interfaces (Request, Response, ServerRequest, Stream, UploadedFile, Uri) and the PSR-17 HTTP factory interfaces. It succeeds and replaces the earlier phly/http package and is one of the most widely used PSR-7 implementations in the PHP ecosystem, with over 3 million monthly downloads.
Because it implements standard PHP-FIG interfaces rather than framework-specific classes, laminas-diactoros is interoperable with any PSR-7/PSR-17-compatible middleware, framework, or HTTP client — it underpins request/response handling in Mezzio and is commonly swapped into other middleware-based PHP stacks that need a standards-compliant HTTP message implementation.
What You Get
- PSR-7
Request,Response,ServerRequest,UploadedFile,Stream, andUriimplementations - PSR-17 factory classes for constructing PSR-7 objects (
RequestFactory,ResponseFactory,StreamFactory,UriFactory,ServerRequestFactory,UploadedFileFactory) - Immutable, value-object-style message classes matching the PSR-7 specification exactly
- Server-request creation helpers that marshal PHP superglobals (
$_SERVER,$_FILES, etc.) into a PSR-7ServerRequest - Broad interoperability with any PSR-7/PSR-17-compatible middleware or framework
Common Use Cases
- Providing the HTTP message layer for middleware-based PHP applications (Mezzio, PSR-15 middleware stacks)
- Building or testing HTTP clients and servers that need standards-compliant request/response objects
- Swapping a framework’s HTTP layer for a decoupled, interface-based implementation to ease testing
- Constructing HTTP messages programmatically for API gateways, proxies, or request/response transformation tools
Under The Hood
Architecture - The library is organized around immutable value objects that implement the PSR-7 interfaces directly: Request/Response compose a Stream for the message body and a headers collection, while ServerRequest additionally models parsed body, query params, uploaded files, and server parameters. PSR-17 factories sit alongside these as thin construction helpers, decoupling how a message is built from what interface it satisfies, so consumers can depend only on the PSR interfaces and swap implementations freely.
Tech Stack - Pure PHP with no runtime dependencies beyond the psr/http-message, psr/http-factory, and psr/http-server-* interface packages it implements. It’s distributed via Composer with PSR-4 autoloading and uses GitHub Actions CI with Psalm static analysis (tracked publicly via Shepherd) and type-coverage badges.
Code Quality - With 2,338 commits from 118 contributors and 47 tagged releases, this is one of the most battle-tested components in the Laminas ecosystem. It maintains a full PHPUnit test suite, enforces strict typing and Psalm-level static analysis, and follows the Laminas coding standard consistently across its immutable message classes.
API Design - Because the API surface is dictated by the PSR-7/PSR-17 specifications rather than invented by the maintainers, method names and semantics (withHeader(), withBody(), getUri(), immutable with*() mutators) are identical to every other PSR-7 implementation — meaning any PHP developer who has used one PSR-7 library already knows this one’s API.