Home

PSR7

PSR-7 is a PHP Standards Recommendation that defines a set of interfaces for representing HTTP messages, most notably requests and responses, along with supporting interfaces for URIs, streams, and uploaded files. It provides a standard contract to promote interoperability between PHP HTTP components and frameworks.

The design emphasizes immutability; instances of the interfaces are intended to be immutable, with operations that

PSR-7 does not prescribe concrete implementations. Instead, it offers the contract that libraries and frameworks can

The standard is typically used in combination with other PSRs. PSR-17 provides factories for creating PSR-7

Versioning and status: PSR-7 has achieved broad adoption and is recognized as a foundational interface in PHP

would
modify
state
returning
new
instances.
Core
interfaces
include
RequestInterface,
ResponseInterface,
ServerRequestInterface,
UriInterface,
StreamInterface,
and
UploadedFileInterface.
Implementations
supply
concrete
behavior,
while
the
interfaces
describe
how
they
should
interact,
including
header
management,
message
bodies,
and
URI
handling.
implement.
Many
PHP
projects
rely
on
PSR-7-compatible
libraries
for
HTTP
message
handling,
such
as
HTTP
message
implementations
in
Guzzle,
Zend
Diactoros,
Laminas
Diactoros,
Nyholm
PSR-7,
and
others;
frameworks
often
integrate
these
pieces
or
provide
adapters.
objects,
PSR-18
defines
a
client
interface
for
making
HTTP
requests
using
PSR-7
messages,
and
PSR-15
defines
HTTP
server
request
handlers
that
can
consume
PSR-7
messages.
Middleware
ecosystems
also
leverage
PSR-7
to
pass
and
transform
messages
along
pipelines.
HTTP
ecosystems.
It
continues
to
influence
how
HTTP
messages
are
represented
in
PHP
applications,
alongside
newer
standards
that
complement
or
extend
its
functionality.