Implementing PSR-7 value object classes
In order to work with PSR-7 requests and responses, we first need to define a series of value objects. These are classes that represent logical objects used in web-based activities such as URIs, file uploads, and streaming request or response bodies.
Getting ready
The source code for the PSR-7 interfaces is available as a Composer
package. It is considered a best practice to use Composer
to manage external software, including PSR-7 interfaces.
How to do it...
- First of all, go to the following URL to obtain the latest versions of the PSR-7 interface definitions: https://github.com/php-fig/http-message. The source code is also available. At the time of writing, the following definitions are available:
Interface
Extends
Notes
What the methods handle
MessageInterface
Defines methods common to HTTP messages
Headers, message body (that is, content), and protocol
RequestInterface
MessageInterface
Represents requests generated by a client
The...