psr/http-message
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The psr/http-message is a PHP standard recommendation package that provides a common interface for HTTP messages. It serves as an abstract layer for a HTTP message, but doesn't implement a HTTP message of its own. It's crucial to note that this package is all about defining standardized rules for dealing with HTTP requests and responses in PHP, which makes the interoperability among different PHP libraries and frameworks easier.
Using the psr/http-message package involves implementing it in conjunction with other packages that provide an implementation of HTTP messages. Here is a simple example, assuming you are using some package that relies on psr/http-message:
<?php
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
function (ServerRequestInterface $request): ResponseInterface
{
$response = new \SomeVendor\ImplementationOfPsr7\Response();
$response->getBody()->write("Hello, world!");
return $response;
}
In the code example above, we are using the ServerRequestInterface
and ResponseInterface
which are part of the psr/http-message standard. We are creating a new response and writing a body to it.
Remember that the actual functionality will come from the specific implementation that you use in conjunction with psr/http-message, such as Slim, Guzzle, Symfony, etc.
The documentation for the psr/http-message package, including information on the methods for PSR-7 interfaces and usage guidelines, can be found exclusively on the psr/http-message GitHub repository. The specific documents are PSR-7 Interfaces Method List
and the PSR-7 Usage Guide
.