EXC | DEV | Documentation


Use the request object to get information regarding the HTTP request that is currently being handle by your back-end app.

Using the request

Obtain an instance of the request object with \exc\app::request().

$request = \exc\app::request();

Getting parameters

Traditional data send using query params (the parameters after a ?) or form data send over an HTTP POST is available using the params array:

//for a url like

$request = \exc\app::request();

$id = $request->params['id'];

$type = 'visitor';
if( $request->has('type') ){
	$type = $request->params['type'];

Getting a JSON document

JSON data send with a content-type of application/json or application/vnd.api+json is available in the document array. JSON data is the de-facto payload that your back-end will receive from API requests and most interactions with an EXC front-end.

$request = \exc\app::request();

$id = $request->document['id'];


Property $method

A string with the corresponding HTTP method used, for example "get", "post", "delete", "put".

$method = $request->method

Property $params

Array of key-value pairs representing HTTP query-params or form data.

$value = $request->params['name']

Property $document

Array of key-value pairs representing a JSON payload.

$value = $request->document['name']

Property $elements

A zero based array with the URL elements of an API request.

$value = $request->elements[0]

Function has()

Returns true if a key exists in the request parameters, else it returns false.



$keyName (string)(required) The name of the key to test.

Function param()

Returns the value of a request parameter if exists.

$value = $request->param($keyName, $defaultValue)

Returns the value of the parameter if present, else it returns the value passed in $defaultValue or else it returns NULL.


$keyName (string)(required) The name of the key to get its value.
$defaultValue (any)(optional) The value to return if the key is not present.

Fork me on GitHub