Request Class

The request class is an object-oriented representation of an HTTP request. This is meant to work for both incoming, such as a request to the application from a browser, and outgoing requests, like would be used to send a request from the application to a third-party application. This class provides the common functionality they both need, but both cases have custom classes that extend from the Request class to add specific functionality.

See the documentation for the IncomingRequest Class and CURLRequest Class for more usage details.

Class Reference

Returns:The user’s IP Address, if it can be detected, or null. If the IP address is not a valid IP addresss, then will return
Return type:string

Returns the IP address for the current user. If the IP address is not valid, the method will return ‘’:

echo $request->getIPAddress();


This method takes into account the App->proxy_ips setting and will return the reported HTTP_X_FORWARDED_FOR, HTTP_CLIENT_IP, HTTP_X_CLIENT_IP, or HTTP_X_CLUSTER_CLIENT_IP address for the allowed IP address.

validIP($ip[, $which = ''])
  • $ip (string) – IP address
  • $which (string) – IP protocol (‘ipv4’ or ‘ipv6’)

true if the address is valid, false if not

Return type:


Takes an IP address as input and returns true or false (boolean) depending on whether it is valid or not.


The $request->getIPAddress() method above automatically validates the IP address.

if ( ! $request->validIP($ip))
    echo 'Not Valid';
    echo 'Valid';

Accepts an optional second string parameter of ‘ipv4’ or ‘ipv6’ to specify an IP format. The default checks for both formats.

method([$upper = FALSE])
  • $upper (bool) – Whether to return the request method name in upper or lower case

HTTP request method

Return type:


Returns the $_SERVER['REQUEST_METHOD'], with the option to set it in uppercase or lowercase.

echo $request->method(TRUE); // Outputs: POST
echo $request->method(FALSE); // Outputs: post
echo $request->method(); // Outputs: post
getServer($index[, $filter = NULL])
  • $index (mixed) – Value name
  • $filter (int) – The type of filter to apply. A list of filters can be found here.

$_SERVER item value if found, NULL if not

Return type:


This method is identical to the post(), get() and cookie() methods from the IncomingRequest Class, only it fetches getServer data ($_SERVER):


To return an array of multiple $_SERVER values, pass all the required keys as an array.

$require->getServer(array('SERVER_PROTOCOL', 'REQUEST_URI'));