PSR-7 HTTP Message Interfaces is a set of standardized PHP interfaces for representing HTTP request and response messages, URIs, streams, and uploaded files as immutable value objects. These interfaces define a common contract that enables interoperability between PHP frameworks and libraries when handling HTTP messages, ensuring that any implementation can be used interchangeably.
The interfaces model HTTP messages as immutable value objects where any modification produces a new instance, guaranteeing message integrity throughout the request lifecycle. They provide case-insensitive header access and retrieval, support for multi-valued headers, and stream-based body handling that enables efficient processing of large payloads without loading them entirely into memory. For server-side requests, the interfaces abstract PHP superglobals into structured objects with attributes for application-specific routing, and normalize uploaded file trees into consistent nested structures with safe file movement and stream access methods.
URI handling is provided through immutable value objects that parse RFC 3986 URIs once and expose individual component accessors for scheme, authority, path, query, and fragment. The interfaces also include validation mechanisms that reject malformed header names and values to prevent injection attacks and parsing errors. The package consists solely of interfaces and does not include any implementations, serving as a foundational contract for the PHP ecosystem.