Methods
Constructor
__construct(array $params_get, array $params_post, array $cookies, array $server, array $files, string $body)
Create a new Request object and define all of its request data
Parameters
$params_get
array
$params_post
array
$cookies
array
$server
array
$files
array
$body
string
Magic "__get" method
__get(string $param) : string
Allows the ability to arbitrarily request a parameter from this instance
while treating it as an instance property
Parameters
$param
string
The name of the parameter
Returns
string
Magic "__isset" method
__isset(string $param) : boolean
Allows the ability to arbitrarily check the existence of a parameter
from this instance while treating it as an instance property
Parameters
$param
string
The name of the parameter
Returns
boolean
Magic "__set" method
__set(string $param, mixed $value) : void
Allows the ability to arbitrarily set a parameter from this instance
while treating it as an instance property
NOTE: This currently sets the "named" parameters, since that's the
one collection that we have the most sane control over
Parameters
$param
string
The name of the parameter
$value
mixed
The value of the parameter
Magic "__unset" method
__unset(string $param) : void
Allows the ability to arbitrarily remove a parameter from this instance
while treating it as an instance property
Parameters
$param
string
The name of the parameter
Gets the request body
body() : string
Create a new request object using the built-in "superglobals"
createFromGlobals() : \Klein\Request
Static
Gets a unique ID for the request
id(boolean $hash) : string
Generates one on the first call
Parameters
$hash
boolean
Whether or not to hash the ID on creation
Returns
string
Gets the request IP address
ip() : string
Is the request secure?
isSecure() : boolean
Gets the request method, or checks it against $is
method(string $is, boolean $allow_override) : string
// POST request example
$request->method() // returns 'POST'
$request->method('post') // returns true
$request->method('get') // returns false
Parameters
$is
string
The method to check the current request method against
$allow_override
boolean
Whether or not to allow HTTP method overriding via header or params
Returns
string
| boolean
Return a request parameter, or $default if it doesn't exist
param(string $key, mixed $default) : string
Parameters
$key
string
The name of the parameter to return
$default
mixed
The default value of the parameter if it contains no value
Returns
string
Returns all parameters (GET, POST, named, and cookies) that match the mask
params(array $mask, boolean $fill_with_nulls) : array
Takes an optional mask param that contains the names of any params
you'd like this method to exclude in the returned array
Parameters
$mask
array
The parameter mask array
$fill_with_nulls
boolean
Whether or not to fill the returned array
with null values to match the given mask
Returns
array
Returns the POST parameters collection
paramsPost() : \Klein\DataCollection\DataCollection
Get the request's pathname
pathname() : string
Adds to or modifies the current query string
query(string $key, mixed $value) : string
Parameters
$key
string
The name of the query param
$value
mixed
The value of the query param
Returns
string
Gets the request URI
uri() : string
Gets the request user agent
userAgent() : string
Properties