As we said, the request object will encapsulate all the data related to a request and provide the developer with a fluent API to access the data. Let's take a look at the details of the request object in order to understand how to use it and what it can offer to us:
use Zend\Http\Request; $string = "GET /foo HTTP/1.1\r\n\r\nSome Content"; $request = Request::fromString($string); $request->getMethod(); $request->getUri(); $request->getUriString(); $request->getVersion(); $request->getContent();
This example comes directly from the documentation and shows how a request object can be created from a string, and then access some data related with the request using the methods provided. So, every time we need to know something related to the request, we will access this object to get the data we need.
If we check the code on Zend\Http\PhpEnvironment\Request.php
, the first thing we can notice is that the data is populated on the constructor using the superglobal...