Developing a PSR-7 Request class
One of the key characteristics of PSR-7 middleware is the use of Request and Response classes. When applied, this enables different blocks of software to perform together without sharing any specific knowledge between them. In this context, a request class should encompass all aspects of the original user request, including such items as browser settings, the original URL requested, parameters passed, and so forth.
How to do it...
- First, be sure to define classes to represent the
Uri
,Stream
, andUploadedFile
value objects, as described in the previous recipe. - Now we are ready to define the core
Application\MiddleWare\Message
class. This class consumesStream
andUri
and implementsPsr\Http\Message\MessageInterface ...
Get PHP 7: Real World Application Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.