Request
extends Request
in package
HTTP Request for current PHP environment
Table of Contents
Constants
- METHOD_CONNECT = 'CONNECT'
- METHOD_DELETE = 'DELETE'
- METHOD_GET = 'GET'
- METHOD_HEAD = 'HEAD'
- METHOD_OPTIONS = 'OPTIONS'
- METHOD_PATCH = 'PATCH'
- METHOD_POST = 'POST'
- METHOD_PROPFIND = 'PROPFIND'
- METHOD_PUT = 'PUT'
- METHOD_TRACE = 'TRACE'
- VERSION_10 = '1.0'
- VERSION_11 = '1.1'
- VERSION_2 = '2'
Properties
- $allowCustomMethods : bool
- $basePath : string
- Base Path of the application.
- $baseUrl : string
- Base URL of the application.
- $content : mixed
- $envParams : ParametersInterface
- PHP environment params ($_ENV)
- $fileParams : ParametersInterface
- $headers : Headers|null
- $metadata : array<string|int, mixed>
- $method : string
- $postParams : ParametersInterface
- $queryParams : ParametersInterface
- $requestUri : string
- Actual request URI, independent of the platform.
- $serverParams : ParametersInterface
- PHP server params ($_SERVER)
- $uri : string|Http
- $version : string
Methods
- __construct() : mixed
- Construct Instantiates request.
- __toString() : string
- Allow PHP casting of this object
- fromString() : static
- A factory that produces a Request object from a well-formed Http Request string
- getAllowCustomMethods() : bool
- getBasePath() : string
- Get the base path.
- getBaseUrl() : string
- Get the base URL.
- getContent() : string
- Get raw request body
- getCookie() : Cookie|bool
- Return the Cookie header, this is the same as calling $request->getHeaders()->get('Cookie');
- getEnv() : ParametersInterface|mixed
- Return the parameter container responsible for env parameters or a single parameter value.
- getFiles() : ParametersInterface|mixed
- Return the parameter container responsible for file parameters or a single file.
- getHeader() : Headers|bool|HeaderInterface|ArrayIterator
- Get all headers of a certain name/type.
- getHeaders() : Headers|bool|HeaderInterface|ArrayIterator
- Return the header container responsible for headers or all headers of a certain name/type
- getMetadata() : mixed
- Retrieve all metadata or a single metadatum as specified by key
- getMethod() : string
- Return the method for this request
- getPost() : ParametersInterface|mixed
- Return the parameter container responsible for post parameters or a single post parameter.
- getQuery() : ParametersInterface|mixed
- Return the parameter container responsible for query parameters or a single query parameter
- getRequestUri() : string
- Get the request URI.
- getServer() : ParametersInterface|mixed
- Return the parameter container responsible for server parameters or a single parameter value.
- getUri() : Http
- Return the URI for this request object
- getUriString() : string
- Return the URI for this request object as a string
- getVersion() : string
- Return the HTTP version for this request
- isConnect() : bool
- Is this a CONNECT method request?
- isDelete() : bool
- Is this a DELETE method request?
- isFlashRequest() : bool
- Is this a Flash request?
- isGet() : bool
- Is this a GET method request?
- isHead() : bool
- Is this a HEAD method request?
- isOptions() : bool
- Is this an OPTIONS method request?
- isPatch() : bool
- Is this a PATCH method request?
- isPost() : bool
- Is this a POST method request?
- isPropFind() : bool
- Is this a PROPFIND method request?
- isPut() : bool
- Is this a PUT method request?
- isTrace() : bool
- Is this a TRACE method request?
- isXmlHttpRequest() : bool
- Is the request a Javascript XMLHttpRequest?
- renderRequestLine() : string
- Return the formatted request line (first line) for this http request
- setAllowCustomMethods() : mixed
- setBasePath() : $this
- Set the base path.
- setBaseUrl() : $this
- Set the base URL.
- setContent() : Message
- Set message content
- setCookies() : $this
- Set cookies
- setEnv() : $this
- Provide an alternate Parameter Container implementation for env parameters in this object, (this is NOT the primary API for value setting, for that see env())
- setFiles() : $this
- Provide an alternate Parameter Container implementation for file parameters in this object, (this is NOT the primary API for value setting, for that see getFiles())
- setHeaders() : $this
- Provide an alternate Parameter Container implementation for headers in this object, (this is NOT the primary API for value setting, for that see getHeaders())
- setMetadata() : Message
- Set message metadata
- setMethod() : $this
- Set the method for this request
- setPost() : $this
- Provide an alternate Parameter Container implementation for post parameters in this object, (this is NOT the primary API for value setting, for that see getPost())
- setQuery() : $this
- Provide an alternate Parameter Container implementation for query parameters in this object, (this is NOT the primary API for value setting, for that see getQuery())
- setRequestUri() : $this
- Set the request URI.
- setServer() : $this
- Provide an alternate Parameter Container implementation for server parameters in this object, (this is NOT the primary API for value setting, for that see getServer())
- setUri() : $this
- Set the URI/URL for this request, this can be a string or an instance of Laminas\Uri\Http
- setVersion() : $this
- Set the HTTP version for this object, one of 1.0, 1.1 or 2 (AbstractMessage::VERSION_10, AbstractMessage::VERSION_11, AbstractMessage::VERSION_2)
- toString() : string
- detectBasePath() : string
- Autodetect the base path of the request
- detectBaseUrl() : string
- Auto-detect the base path from the request environment
- detectRequestUri() : string
- Detect the base URI for the request
- mapPhpFileParam() : mixed
- mapPhpFiles() : array<string|int, mixed>
- Convert PHP superglobal $_FILES into more sane parameter=value structure This handles form file input with brackets (name=files[])
Constants
METHOD_CONNECT
public
mixed
METHOD_CONNECT
= 'CONNECT'
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_PATCH
public
mixed
METHOD_PATCH
= 'PATCH'
METHOD_POST
public
mixed
METHOD_POST
= 'POST'
METHOD_PROPFIND
public
mixed
METHOD_PROPFIND
= 'PROPFIND'
METHOD_PUT
public
mixed
METHOD_PUT
= 'PUT'
METHOD_TRACE
public
mixed
METHOD_TRACE
= 'TRACE'
VERSION_10
public
mixed
VERSION_10
= '1.0'
VERSION_11
public
mixed
VERSION_11
= '1.1'
VERSION_2
public
mixed
VERSION_2
= '2'
Properties
$allowCustomMethods
protected
bool
$allowCustomMethods
= true
$basePath
Base Path of the application.
protected
string
$basePath
$baseUrl
Base URL of the application.
protected
string
$baseUrl
$content
protected
mixed
$content
= ''
$envParams
PHP environment params ($_ENV)
protected
ParametersInterface
$envParams
$fileParams
protected
ParametersInterface
$fileParams
$headers
protected
Headers|null
$headers
$metadata
protected
array<string|int, mixed>
$metadata
= []
$method
protected
string
$method
= self::METHOD_GET
$postParams
protected
ParametersInterface
$postParams
$queryParams
protected
ParametersInterface
$queryParams
$requestUri
Actual request URI, independent of the platform.
protected
string
$requestUri
$serverParams
PHP server params ($_SERVER)
protected
ParametersInterface
$serverParams
$uri
protected
string|Http
$uri
$version
protected
string
$version
= self::VERSION_11
Methods
__construct()
Construct Instantiates request.
public
__construct([bool $allowCustomMethods = true ]) : mixed
Parameters
- $allowCustomMethods : bool = true
__toString()
Allow PHP casting of this object
public
__toString() : string
Return values
stringfromString()
A factory that produces a Request object from a well-formed Http Request string
public
static fromString(string $string[, bool $allowCustomMethods = true ]) : static
Parameters
- $string : string
- $allowCustomMethods : bool = true
Tags
Return values
staticgetAllowCustomMethods()
public
getAllowCustomMethods() : bool
Return values
boolgetBasePath()
Get the base path.
public
getBasePath() : string
Return values
stringgetBaseUrl()
Get the base URL.
public
getBaseUrl() : string
Return values
stringgetContent()
Get raw request body
public
getContent() : string
Return values
stringgetCookie()
Return the Cookie header, this is the same as calling $request->getHeaders()->get('Cookie');
public
getCookie() : Cookie|bool
Tags
Return values
Cookie|boolgetEnv()
Return the parameter container responsible for env parameters or a single parameter value.
public
getEnv([string|null $name = null ][, mixed|null $default = null ]) : ParametersInterface|mixed
Parameters
- $name : string|null = null
-
Parameter name to retrieve, or null to get the whole container.
- $default : mixed|null = null
-
Default value to use when the parameter is missing.
Return values
ParametersInterface|mixedgetFiles()
Return the parameter container responsible for file parameters or a single file.
public
getFiles([string|null $name = null ][, mixed|null $default = null ]) : ParametersInterface|mixed
Parameters
- $name : string|null = null
-
Parameter name to retrieve, or null to get the whole container.
- $default : mixed|null = null
-
Default value to use when the parameter is missing.
Return values
ParametersInterface|mixedgetHeader()
Get all headers of a certain name/type.
public
getHeader(string|null $name[, mixed|null $default = false ]) : Headers|bool|HeaderInterface|ArrayIterator
Parameters
- $name : string|null
-
Header name to retrieve, or null to get the whole container.
- $default : mixed|null = false
-
Default value to use when the requested header is missing.
Tags
Return values
Headers|bool|HeaderInterface|ArrayIteratorgetHeaders()
Return the header container responsible for headers or all headers of a certain name/type
public
getHeaders([string|null $name = null ][, mixed|null $default = false ]) : Headers|bool|HeaderInterface|ArrayIterator
Parameters
- $name : string|null = null
-
Header name to retrieve, or null to get the whole container.
- $default : mixed|null = false
-
Default value to use when the requested header is missing.
Tags
Return values
Headers|bool|HeaderInterface|ArrayIteratorgetMetadata()
Retrieve all metadata or a single metadatum as specified by key
public
getMetadata([null|string|int $key = null ][, null|mixed $default = null ]) : mixed
Parameters
- $key : null|string|int = null
- $default : null|mixed = null
Tags
getMethod()
Return the method for this request
public
getMethod() : string
Return values
stringgetPost()
Return the parameter container responsible for post parameters or a single post parameter.
public
getPost([string|null $name = null ][, mixed|null $default = null ]) : ParametersInterface|mixed
Parameters
- $name : string|null = null
-
Parameter name to retrieve, or null to get the whole container.
- $default : mixed|null = null
-
Default value to use when the parameter is missing.
Return values
ParametersInterface|mixedgetQuery()
Return the parameter container responsible for query parameters or a single query parameter
public
getQuery([string|null $name = null ][, mixed|null $default = null ]) : ParametersInterface|mixed
Parameters
- $name : string|null = null
-
Parameter name to retrieve, or null to get the whole container.
- $default : mixed|null = null
-
Default value to use when the parameter is missing.
Return values
ParametersInterface|mixedgetRequestUri()
Get the request URI.
public
getRequestUri() : string
Return values
stringgetServer()
Return the parameter container responsible for server parameters or a single parameter value.
public
getServer([string|null $name = null ][, mixed|null $default = null ]) : ParametersInterface|mixed
Parameters
- $name : string|null = null
-
Parameter name to retrieve, or null to get the whole container.
- $default : mixed|null = null
-
Default value to use when the parameter is missing.
Tags
Return values
ParametersInterface|mixedgetUri()
Return the URI for this request object
public
getUri() : Http
Return values
HttpgetUriString()
Return the URI for this request object as a string
public
getUriString() : string
Return values
stringgetVersion()
Return the HTTP version for this request
public
getVersion() : string
Return values
stringisConnect()
Is this a CONNECT method request?
public
isConnect() : bool
Return values
boolisDelete()
Is this a DELETE method request?
public
isDelete() : bool
Return values
boolisFlashRequest()
Is this a Flash request?
public
isFlashRequest() : bool
Return values
boolisGet()
Is this a GET method request?
public
isGet() : bool
Return values
boolisHead()
Is this a HEAD method request?
public
isHead() : bool
Return values
boolisOptions()
Is this an OPTIONS method request?
public
isOptions() : bool
Return values
boolisPatch()
Is this a PATCH method request?
public
isPatch() : bool
Return values
boolisPost()
Is this a POST method request?
public
isPost() : bool
Return values
boolisPropFind()
Is this a PROPFIND method request?
public
isPropFind() : bool
Return values
boolisPut()
Is this a PUT method request?
public
isPut() : bool
Return values
boolisTrace()
Is this a TRACE method request?
public
isTrace() : bool
Return values
boolisXmlHttpRequest()
Is the request a Javascript XMLHttpRequest?
public
isXmlHttpRequest() : bool
Should work with Prototype/Script.aculo.us, possibly others.
Return values
boolrenderRequestLine()
Return the formatted request line (first line) for this http request
public
renderRequestLine() : string
Return values
stringsetAllowCustomMethods()
public
setAllowCustomMethods(bool $strictMethods) : mixed
Parameters
- $strictMethods : bool
setBasePath()
Set the base path.
public
setBasePath(string $basePath) : $this
Parameters
- $basePath : string
Return values
$thissetBaseUrl()
Set the base URL.
public
setBaseUrl(string $baseUrl) : $this
Parameters
- $baseUrl : string
Return values
$thissetContent()
Set message content
public
setContent(mixed $value) : Message
Parameters
- $value : mixed
Return values
MessagesetCookies()
Set cookies
public
setCookies(string|array<string, string> $cookie) : $this
Instantiate and set cookies.
Parameters
- $cookie : string|array<string, string>
Return values
$thissetEnv()
Provide an alternate Parameter Container implementation for env parameters in this object, (this is NOT the primary API for value setting, for that see env())
public
setEnv(ParametersInterface $env) : $this
Parameters
- $env : ParametersInterface
Return values
$thissetFiles()
Provide an alternate Parameter Container implementation for file parameters in this object, (this is NOT the primary API for value setting, for that see getFiles())
public
setFiles(ParametersInterface $files) : $this
Parameters
- $files : ParametersInterface
Return values
$thissetHeaders()
Provide an alternate Parameter Container implementation for headers in this object, (this is NOT the primary API for value setting, for that see getHeaders())
public
setHeaders(Headers $headers) : $this
Parameters
- $headers : Headers
Tags
Return values
$thissetMetadata()
Set message metadata
public
setMetadata(string|int|array<string|int, mixed>|Traversable $spec[, mixed $value = null ]) : Message
Non-destructive setting of message metadata; always adds to the metadata, never overwrites the entire metadata container.
Parameters
- $spec : string|int|array<string|int, mixed>|Traversable
- $value : mixed = null
Tags
Return values
MessagesetMethod()
Set the method for this request
public
setMethod(string $method) : $this
Parameters
- $method : string
Tags
Return values
$thissetPost()
Provide an alternate Parameter Container implementation for post parameters in this object, (this is NOT the primary API for value setting, for that see getPost())
public
setPost(ParametersInterface $post) : $this
Parameters
- $post : ParametersInterface
Return values
$thissetQuery()
Provide an alternate Parameter Container implementation for query parameters in this object, (this is NOT the primary API for value setting, for that see getQuery())
public
setQuery(ParametersInterface $query) : $this
Parameters
- $query : ParametersInterface
Return values
$thissetRequestUri()
Set the request URI.
public
setRequestUri(string $requestUri) : $this
Parameters
- $requestUri : string
Return values
$thissetServer()
Provide an alternate Parameter Container implementation for server parameters in this object, (this is NOT the primary API for value setting, for that see getServer())
public
setServer(ParametersInterface $server) : $this
Parameters
- $server : ParametersInterface
Return values
$thissetUri()
Set the URI/URL for this request, this can be a string or an instance of Laminas\Uri\Http
public
setUri(string|Http $uri) : $this
Parameters
- $uri : string|Http
Tags
Return values
$thissetVersion()
Set the HTTP version for this object, one of 1.0, 1.1 or 2 (AbstractMessage::VERSION_10, AbstractMessage::VERSION_11, AbstractMessage::VERSION_2)
public
setVersion(string $version) : $this
Parameters
- $version : string
-
(Must be 1.0, 1.1 or 2)
Tags
Return values
$thistoString()
public
toString() : string
Return values
stringdetectBasePath()
Autodetect the base path of the request
protected
detectBasePath() : string
Uses several criteria to determine the base path of the request.
Return values
stringdetectBaseUrl()
Auto-detect the base path from the request environment
protected
detectBaseUrl() : string
Uses a variety of criteria in order to detect the base URL of the request (i.e., anything additional to the document root).
Return values
stringdetectRequestUri()
Detect the base URI for the request
protected
detectRequestUri() : string
Looks at a variety of criteria in order to attempt to autodetect a base URI, including rewrite URIs, proxy URIs, etc.
Return values
stringmapPhpFileParam()
protected
mapPhpFileParam(array<string|int, mixed> &$array, string $paramName, int|string $index, string|array<string|int, mixed> $value) : mixed
Parameters
- $array : array<string|int, mixed>
- $paramName : string
- $index : int|string
- $value : string|array<string|int, mixed>
mapPhpFiles()
Convert PHP superglobal $_FILES into more sane parameter=value structure This handles form file input with brackets (name=files[])
protected
mapPhpFiles() : array<string|int, mixed>