3. Request - caligrafy/caligrafy-quill GitHub Wiki
The Request class provides you with the flexibility to get all the information needed about a request made to your application. The Request class exists in the context of a successful route. In other words, if the routing is not successful then there is no easy way to have access to the Request class and to leverage its powerful functionalities.
Learn more about
Routinghere
From the moment a route is successful, the Request class is available for use.
- It can be accessed from the context of any
Classcreated in the/applicationfolder by invoking a global helper method:
request();- In the context of a
Controller, theRequestis a property of these classes:
use Caligrafy\Controller;
class BookController extends Controller {
public function test()
{
dump($this->request); // will return the entire request object
}
} public $method; // retrieves the request method
public $uri; // retrieves the URI
public $fullUri; // retrieves the the full URI including the query parameters
public $userAgent; // retrieves the User Agent of the request
public $cookie; // retrieves the Cookie headers
public $currentRoute; // retrieves the current route
public $fetch; // retrieves an array of all the parameters fetched from the request and the URI
public $parameters; // retrieves an object model of all the request parameters public function fetch($argument); //returns the value of a specific parameter
public function files($HTMLFileName); //returns an array of all the uploaded files through a FORM
public function wantsJson(); //returns true if the request is an API call
public function parameters(); //returns an array of all the request parameters