PHP Class Webiny\Component\Http\Request

Inheritance: use trait Webiny\Component\StdLib\SingletonTrait, use trait Webiny\Component\StdLib\StdLibTrait
Afficher le fichier Open project: Webiny/Framework Class Usage Examples

Méthodes publiques

Méthode Description
env ( string $key = null, mixed $value = null ) : mixed Get a value from $_ENV param for the given $key.
files ( string $name, null | integer $arrayOffset = null ) : File Get the File object for the given $name.
getClientIp ( ) : string Get client ip address.
getConnectionPort ( ) : integer Return the connection port number.
getCurrentUrl ( boolean $asUrlObject = false ) : string | UrlObject Get current url with schema, host, port, request uri and query string.
getHostName ( ) : string Returns the host name.
getPayload ( ) : Payload Returns an array object with all post parameters.
getPost ( ) : Post Returns an array object with all POST parameters.
getQuery ( ) : Query Returns an array object with all GET parameters.
getRequestMethod ( ) : string Get request method from HTTP headers
getTrustedHeaders ( ) : array Get a list of trusted headers.
getTrustedProxies ( ) : array Array of IPs from trusted proxies.
header ( string $key = null, mixed $value = null ) : mixed Get a value from HTTP Headers If key doesn't not exist, $value will be returned and assigned under that key.
isDelete ( ) : boolean Checks if current request method is DELETE.
isGet ( ) : boolean Checks if current request method is GET.
isPatch ( ) : boolean Checks if current request method is PATCH.
isPost ( ) : boolean Checks if current request method is POST.
isPut ( ) : boolean Checks if current request method is PUT.
isRequestSecured ( ) : boolean Check if connection is secured.
payload ( string $key = null, mixed $value = null ) : mixed Get a value from request payload param for the given $key.
post ( string $key = null, mixed $value = null ) : mixed Get a value from $_POST param for the given $key.
query ( string $key = null, mixed $value = null ) : mixed Get a value from $_GET param for the given $key.
server ( ) : Server Access to the $_SERVER parameter over a object wrapper.
setCurrentUrl ( string $url ) This method sets the internal value of currentUrl to $url.
setRequestMethod ( string $requestMethod ) Set the request method.

Méthodes protégées

Méthode Description
init ( ) This function prepare the Request and all of its sub-classes.

Method Details

env() public méthode

If key doesn't not exist, $value will be returned and assigned under that key.
public env ( string $key = null, mixed $value = null ) : mixed
$key string Key for which you wish to get the value.
$value mixed Default value that will be returned if $key doesn't exist.
Résultat mixed Value of the given $key.

files() public méthode

If you have a multi-dimensional upload field name, than you should pass the optional $arrayOffset param to get the right File object.
public files ( string $name, null | integer $arrayOffset = null ) : File
$name string Name of the upload field.
$arrayOffset null | integer Optional array offset for multi-dimensional upload fields.
Résultat Webiny\Component\Http\Request\Files\File

getClientIp() public méthode

This function check and validates headers from trusted proxies.
public getClientIp ( ) : string
Résultat string Client IP address.

getConnectionPort() public méthode

This function check the forwarded headers from trusted proxies.
public getConnectionPort ( ) : integer
Résultat integer Port number.

getCurrentUrl() public méthode

You can get the result in a form of a string or as a url standard object.
public getCurrentUrl ( boolean $asUrlObject = false ) : string | UrlObject
$asUrlObject boolean In which format you want to get the result, url standard object or a string.
Résultat string | Webiny\Component\StdLib\StdObject\UrlObject\UrlObject Current url.

getHostName() public méthode

This function check the forwarded headers from trusted proxies.
public getHostName ( ) : string
Résultat string Host name

getPayload() public méthode

Returns an array object with all post parameters.
public getPayload ( ) : Payload
Résultat Webiny\Component\Http\Request\Payload

getPost() public méthode

Returns an array object with all POST parameters.
public getPost ( ) : Post
Résultat Webiny\Component\Http\Request\Post

getQuery() public méthode

Returns an array object with all GET parameters.
public getQuery ( ) : Query
Résultat Webiny\Component\Http\Request\Query

getRequestMethod() public méthode

Get request method from HTTP headers
public getRequestMethod ( ) : string
Résultat string

getTrustedHeaders() public méthode

Get a list of trusted headers.
public getTrustedHeaders ( ) : array
Résultat array List of trusted headers.

getTrustedProxies() public méthode

Array of IPs from trusted proxies.
public getTrustedProxies ( ) : array
Résultat array

header() public méthode

Get a value from HTTP Headers If key doesn't not exist, $value will be returned and assigned under that key.
public header ( string $key = null, mixed $value = null ) : mixed
$key string Key for which you wish to get the value.
$value mixed Default value that will be returned if $key doesn't exist.
Résultat mixed Value of the given $key.

init() protected méthode

This class is called automatically by SingletonTrait.
protected init ( )

isDelete() public méthode

Checks if current request method is DELETE.
public isDelete ( ) : boolean
Résultat boolean True if it's DELETE.

isGet() public méthode

Checks if current request method is GET.
public isGet ( ) : boolean
Résultat boolean True if it's GET.

isPatch() public méthode

Checks if current request method is PATCH.
public isPatch ( ) : boolean
Résultat boolean True if it's PATCH.

isPost() public méthode

Checks if current request method is POST.
public isPost ( ) : boolean
Résultat boolean True if it's POST.

isPut() public méthode

Checks if current request method is PUT.
public isPut ( ) : boolean
Résultat boolean True if it's PUT.

isRequestSecured() public méthode

This function check the forwarded headers from trusted proxies.
public isRequestSecured ( ) : boolean
Résultat boolean True if connection is secured (https), otherwise false is returned.

payload() public méthode

If key doesn't not exist, $value will be returned and assigned under that key.
public payload ( string $key = null, mixed $value = null ) : mixed
$key string Key for which you wish to get the value.
$value mixed Default value that will be returned if $key doesn't exist.
Résultat mixed Value of the given $key.

post() public méthode

If key doesn't not exist, $value will be returned and assigned under that key.
public post ( string $key = null, mixed $value = null ) : mixed
$key string Key for which you wish to get the value.
$value mixed Default value that will be returned if $key doesn't exist.
Résultat mixed Value of the given $key.

query() public méthode

If key doesn't not exist, $value will be returned and assigned under that key.
public query ( string $key = null, mixed $value = null ) : mixed
$key string Key for which you wish to get the value.
$value mixed Default value that will be returned if $key doesn't exist.
Résultat mixed Value of the given $key.

server() public méthode

Access to the $_SERVER parameter over a object wrapper.
public server ( ) : Server
Résultat Webiny\Component\Http\Request\Server

setCurrentUrl() public méthode

This method will not actually do a redirect, it is used mostly for mocking the internal value.
public setCurrentUrl ( string $url )
$url string Current url.

setRequestMethod() public méthode

Set the request method.
public setRequestMethod ( string $requestMethod )
$requestMethod string Request method name. Example 'GET', 'POST' ...