Request
    
            
            in package
            
        
    
    
    
Leaf HTTP Request --------
This class provides an object-oriented way to interact with the current HTTP request being handled by your application as well as retrieve the input, cookies, and files that were submitted with the request.
Tags
Table of Contents
Constants
- METHOD_DELETE = 'DELETE'
- METHOD_GET = 'GET'
- METHOD_HEAD = 'HEAD'
- METHOD_OPTIONS = 'OPTIONS'
- METHOD_OVERRIDE = '_METHOD'
- METHOD_PATCH = 'PATCH'
- METHOD_POST = 'POST'
- METHOD_PUT = 'PUT'
Properties
- $errors : mixed
- $formDataMediaTypes : mixed
- $validator : Form
- Internal instance of Leaf Form
Methods
- __construct() : mixed
- body() : mixed
- Get all the request data as an associative array
- cookies() : array<string|int, mixed>|string|null
- Fetch COOKIE data
- errors() : array<string|int, mixed>
- Handle errors from validation/auth/upload
- files() : mixed
- Get all files passed into the request.
- flash() : array<string|int, mixed>|string|null
- Display a flash message from the previous request
- get() : mixed
- Returns request data
- getContentCharset() : string|null
- Get Content Charset
- getContentLength() : int
- Get Content-Length
- getContentType() : string|null
- Get Content Type
- getFullUrl() : string
- Get Full URL (scheme + host [ + port if non-standard ] + path + query string)
- getHost() : string
- Get Host
- getHostWithPort() : string
- Get Host with Port
- getIp() : string
- Get IP
- getMediaType() : string|null
- Get Media Type (type/subtype within Content Type header)
- getMediaTypeParams() : array<string|int, mixed>
- Get Media Type Params
- getMethod() : string
- Get HTTP method
- getOrDefault() : mixed
- Returns request data
- getOriginalMethod() : string
- Get original method
- getPath() : string
- Get Path
- getPathInfo() : string|null
- Get Path Info (virtual path)
- getPhysicalPath() : string
- Get physical path
- getPort() : int
- Get Port
- getQueryString() : string|null
- Get query string
- getReferer() : string|null
- Get Referer (for those who can't spell)
- getReferrer() : string|null
- Get Referrer
- getScheme() : string
- Get Scheme (https or http)
- getScriptName() : string
- Get Script Name
- getUrl() : string
- Get URL (scheme + host [ + port if non-standard ])
- getUserAgent() : string|null
- Get User Agent
- hasHeader() : bool
- Find if request has a particular header
- headers() : array<string|int, mixed>|string|null
- Get Headers
- input() : mixed
- Access stream that allows you to read raw data from the request body. **This is not for form data**
- isAjax() : bool
- Is this an AJAX request?
- isFormData() : bool
- Does the Request body contain parsed form data?
- isXhr() : bool
- Is this an XHR request? (alias of Leaf_Http_Request::isAjax)
- methodOverride() : string|null
- Is this a method override request?
- next() : mixed
- Get data passed from the previous middleware
- params() : mixed
- Returns request data
- postData() : mixed
- Return only get request data
- query() : mixed
- Return only get request data
- rawData() : mixed
- Get raw request data
- try() : mixed
- Attempt to retrieve data from the request.
- typeIs() : bool
- Check for request method type
- upload() : array<string|int, mixed>|false
- Store a file from the request.
- uploadAs() : mixed
- Store a file from the request with a given name
- urlData() : mixed
- Return only get request data
- user() : mixed
- Get the authenticated user
- validate() : false|array<string|int, mixed>
- Validate the request data
- validator() : Form
- Return validator instance
- auth() : Auth
- Return the auth instance
Constants
METHOD_DELETE
    public
        mixed
    METHOD_DELETE
    = 'DELETE'
    
    
    
    
METHOD_GET
    public
        mixed
    METHOD_GET
    = 'GET'
    
    
    
    
METHOD_HEAD
    public
        mixed
    METHOD_HEAD
    = 'HEAD'
    
    
    
    
METHOD_OPTIONS
    public
        mixed
    METHOD_OPTIONS
    = 'OPTIONS'
    
    
    
    
METHOD_OVERRIDE
    public
        mixed
    METHOD_OVERRIDE
    = '_METHOD'
    
    
    
    
METHOD_PATCH
    public
        mixed
    METHOD_PATCH
    = 'PATCH'
    
    
    
    
METHOD_POST
    public
        mixed
    METHOD_POST
    = 'POST'
    
    
    
    
METHOD_PUT
    public
        mixed
    METHOD_PUT
    = 'PUT'
    
    
    
    
Properties
$errors
    protected
    static    mixed
    $errors
     = []
    
    
    
    
$formDataMediaTypes
    protected
    static    mixed
    $formDataMediaTypes
     = ['application/x-www-form-urlencoded']
    
    
    
    
$validator
Internal instance of Leaf Form
    protected
    static    Form
    $validator
    
    
    
    
    
Methods
__construct()
    public
                    __construct() : mixed
    body()
Get all the request data as an associative array
    public
            static        body([bool $safeData = true ]) : mixed
    Parameters
- $safeData : bool = true
- 
                    Sanitize output 
cookies()
Fetch COOKIE data
    public
            static        cookies([string|null $key = null ]) : array<string|int, mixed>|string|null
    This method returns a key-value array of Cookie data sent in the HTTP request, or the value of an array key if requested. If the array key does not exist, NULL is returned.
Parameters
- $key : string|null = null
Return values
array<string|int, mixed>|string|nullerrors()
Handle errors from validation/auth/upload
    public
            static        errors() : array<string|int, mixed>
    Return values
array<string|int, mixed>files()
Get all files passed into the request.
    public
            static        files([array<string|int, mixed>|string|null $filenames = null ]) : mixed
    Parameters
- $filenames : array<string|int, mixed>|string|null = null
- 
                    The file(s) you want to get 
flash()
Display a flash message from the previous request
    public
            static        flash([string|null $key = null ]) : array<string|int, mixed>|string|null
    Parameters
- $key : string|null = null
- 
                    The key to get from the flash data 
Return values
array<string|int, mixed>|string|nullget()
Returns request data
    public
            static        get(array<string|int, mixed>|string $params[, bool $safeData = true ]) : mixed
    This method returns get, post, put patch, delete or raw form data or NULL if the data isn't found.
Parameters
- $params : array<string|int, mixed>|string
- 
                    The parameter(s) to return 
- $safeData : bool = true
- 
                    Sanitize output 
getContentCharset()
Get Content Charset
    public
            static        getContentCharset() : string|null
    Return values
string|nullgetContentLength()
Get Content-Length
    public
            static        getContentLength() : int
    Return values
intgetContentType()
Get Content Type
    public
            static        getContentType() : string|null
    Return values
string|nullgetFullUrl()
Get Full URL (scheme + host [ + port if non-standard ] + path + query string)
    public
            static        getFullUrl() : string
    Return values
stringgetHost()
Get Host
    public
            static        getHost() : string
    Return values
stringgetHostWithPort()
Get Host with Port
    public
            static        getHostWithPort() : string
    Return values
stringgetIp()
Get IP
    public
            static        getIp() : string
    Return values
stringgetMediaType()
Get Media Type (type/subtype within Content Type header)
    public
            static        getMediaType() : string|null
    Return values
string|nullgetMediaTypeParams()
Get Media Type Params
    public
            static        getMediaTypeParams() : array<string|int, mixed>
    Return values
array<string|int, mixed>getMethod()
Get HTTP method
    public
            static        getMethod() : string
    Return values
stringgetOrDefault()
Returns request data
    public
            static        getOrDefault([string|null $key = null ][, mixed|null $default = null ]) : mixed
    This method returns get, post, put patch, delete or raw form data or NULL if the data isn't found.
Parameters
- $key : string|null = null
- $default : mixed|null = null
getOriginalMethod()
Get original method
    public
            static        getOriginalMethod() : string
    Return values
stringgetPath()
Get Path
    public
            static        getPath() : string
    Return values
stringgetPathInfo()
Get Path Info (virtual path)
    public
            static        getPathInfo() : string|null
    Return values
string|nullgetPhysicalPath()
Get physical path
    public
            static        getPhysicalPath() : string
    Return values
stringgetPort()
Get Port
    public
            static        getPort() : int
    Return values
intgetQueryString()
Get query string
    public
            static        getQueryString() : string|null
    Return values
string|nullgetReferer()
Get Referer (for those who can't spell)
    public
            static        getReferer() : string|null
    Return values
string|nullgetReferrer()
Get Referrer
    public
            static        getReferrer() : string|null
    Return values
string|nullgetScheme()
Get Scheme (https or http)
    public
            static        getScheme() : string
    Return values
stringgetScriptName()
Get Script Name
    public
            static        getScriptName() : string
    Return values
stringgetUrl()
Get URL (scheme + host [ + port if non-standard ])
    public
            static        getUrl() : string
    Return values
stringgetUserAgent()
Get User Agent
    public
            static        getUserAgent() : string|null
    Return values
string|nullhasHeader()
Find if request has a particular header
    public
            static        hasHeader(string $header) : bool
    Parameters
- $header : string
- 
                    Header to check for 
Return values
boolheaders()
Get Headers
    public
            static        headers([array<string|int, mixed>|string|null $key = null ][, bool $safeData = true ]) : array<string|int, mixed>|string|null
    This method returns a key-value array of headers sent in the HTTP request, or the value of a hash key if requested. If the array key does not exist, NULL is returned.
Parameters
- $key : array<string|int, mixed>|string|null = null
- 
                    The header(s) to return 
- $safeData : bool = true
- 
                    Attempt to sanitize headers 
Return values
array<string|int, mixed>|string|nullinput()
Access stream that allows you to read raw data from the request body. **This is not for form data**
    public
            static        input([bool $safeData = true ]) : mixed
    Parameters
- $safeData : bool = true
- 
                    Sanitize data? 
isAjax()
Is this an AJAX request?
    public
            static        isAjax() : bool
    Return values
boolisFormData()
Does the Request body contain parsed form data?
    public
            static        isFormData() : bool
    Return values
boolisXhr()
Is this an XHR request? (alias of Leaf_Http_Request::isAjax)
    public
            static        isXhr() : bool
    Return values
boolmethodOverride()
Is this a method override request?
    public
            static        methodOverride() : string|null
    Return values
string|nullnext()
Get data passed from the previous middleware
    public
            static        next([string|null $key = null ]) : mixed
    Parameters
- $key : string|null = null
- 
                    The key to get from the middleware data 
params()
Returns request data
    public
            static        params([string|null $key = null ][, mixed|null $default = null ]) : mixed
    This method returns get, post, put patch, delete or raw form data or NULL if the data isn't found.
Parameters
- $key : string|null = null
- $default : mixed|null = null
postData()
Return only get request data
    public
            static        postData([string|array<string|int, mixed> $item = null ][, mixed $default = null ]) : mixed
    Parameters
- $item : string|array<string|int, mixed> = null
- 
                    The items to output 
- $default : mixed = null
- 
                    The default value to return if no data is available 
query()
Return only get request data
    public
            static        query([string|array<string|int, mixed> $item = null ][, mixed $default = null ]) : mixed
    Parameters
- $item : string|array<string|int, mixed> = null
- 
                    The items to output 
- $default : mixed = null
- 
                    The default value to return if no data is available 
rawData()
Get raw request data
    public
            static        rawData([string|array<string|int, mixed> $item = null ][, mixed $default = null ]) : mixed
    Parameters
- $item : string|array<string|int, mixed> = null
- 
                    The items to output 
- $default : mixed = null
- 
                    The default value to return if no data is available 
try()
Attempt to retrieve data from the request.
    public
            static        try(array<string|int, mixed> $params[, bool $safeData = true ][, bool $noEmptyString = false ]) : mixed
    Data which is not found in the request parameters will
be completely removed instead of returning null. Use get
if you want to return null or params if you want to set
a default value.
Parameters
- $params : array<string|int, mixed>
- 
                    The parameters to return 
- $safeData : bool = true
- 
                    Sanitize output? 
- $noEmptyString : bool = false
- 
                    Remove empty strings from return data? 
typeIs()
Check for request method type
    public
            static        typeIs(string $type) : bool
    Parameters
- $type : string
- 
                    The type of request to check for 
Return values
boolupload()
Store a file from the request.
    public
            static        upload(string $key, string $destination[, array<string|int, mixed> $config = [] ]) : array<string|int, mixed>|false
    Parameters
- $key : string
- 
                    The name of the file input the request. 
- $destination : string
- 
                    The directory where the file should be stored. 
- $config : array<string|int, mixed> = []
- 
                    Optional configurations: max_file_size, file_type, extensions 
Return values
array<string|int, mixed>|false —An array containing the status or false for a failure.
uploadAs()
Store a file from the request with a given name
    public
            static        uploadAs(string $key, string $destination, string $name[, array<string|int, mixed> $config = [] ]) : mixed
    Parameters
- $key : string
- 
                    The name of the file input the request. 
- $destination : string
- 
                    The directory where the file should be stored. 
- $name : string
- 
                    The name to store the file as. 
- $config : array<string|int, mixed> = []
- 
                    Optional configurations: max_file_size, file_type, extensions 
urlData()
Return only get request data
    public
            static        urlData([string|array<string|int, mixed> $item = null ][, mixed $default = null ]) : mixed
    Parameters
- $item : string|array<string|int, mixed> = null
- 
                    The items to output 
- $default : mixed = null
- 
                    The default value to return if no data is available 
user()
Get the authenticated user
    public
            static        user() : mixed
    validate()
Validate the request data
    public
            static        validate(array<string|int, mixed> $rules[, bool $returnFullData = false ]) : false|array<string|int, mixed>
    Parameters
- $rules : array<string|int, mixed>
- 
                    The rules to validate against 
- $returnFullData : bool = false
- 
                    Return the full data or just the validated data? 
Return values
false|array<string|int, mixed> —Returns false if validation fails, or the validated data if validation passes
validator()
Return validator instance
    public
            static        validator() : Form
    Return values
Formauth()
Return the auth instance
    protected
            static        auth() : Auth