PSR-7¶
PSR-7¶
Standard of the PHP Framework Interop Group that defines common interfaces for handling HTTP messages.
Psr\Http\Message\MessageInterfacePsr\Http\Message\RequestInterfacePsr\Http\Message\ResponseInterfacePsr\Http\Message\ServerRequestInterfacePsr\Http\Message\StreamInterfacePsr\Http\Message\UploadedFileInterfacePsr\Http\Message\UriInterface
Example:
// empty array if not found
$header = $request->getHeader('Accept');
// empty string if not found
$header = $request->getHeaderLine('Accept');
// check the presence of a header
if (! $request->hasHeader('Accept')) {}
// returns the parameters in a query string
$query = $request->getQueryParams();
Immutability¶
PSR-7 requests are immutable objects; a change in the data will return a new instance of the object. The stream objects of PSR-7 are not immutable.