HumHub Documentation (unofficial)

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'

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 = ''

$metadata

protected array<string|int, mixed> $metadata = []

$method

protected string $method = self::METHOD_GET

$requestUri

Actual request URI, independent of the platform.

protected string $requestUri

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
string

fromString()

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
throws
InvalidArgumentException
Return values
static

getAllowCustomMethods()

public getAllowCustomMethods() : bool
Return values
bool

getBasePath()

Get the base path.

public getBasePath() : string
Return values
string

getBaseUrl()

Get the base URL.

public getBaseUrl() : string
Return values
string

getContent()

Get raw request body

public getContent() : string
Return values
string

getCookie()

Return the Cookie header, this is the same as calling $request->getHeaders()->get('Cookie');

public getCookie() : Cookie|bool
Tags
convenience

$request->getHeaders()->get('Cookie');

Return values
Cookie|bool

getEnv()

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|mixed

getFiles()

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|mixed

getHeader()

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
see
Request::getHeaders()
Return values
Headers|bool|HeaderInterface|ArrayIterator

getHeaders()

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
see
Headers::get()
Return values
Headers|bool|HeaderInterface|ArrayIterator

getMetadata()

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
throws
InvalidArgumentException

getMethod()

Return the method for this request

public getMethod() : string
Return values
string

getPost()

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|mixed

getQuery()

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|mixed

getRequestUri()

Get the request URI.

public getRequestUri() : string
Return values
string

getServer()

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
see
http://www.faqs.org/rfcs/rfc3875.html
Return values
ParametersInterface|mixed

getUri()

Return the URI for this request object

public getUri() : Http
Return values
Http

getUriString()

Return the URI for this request object as a string

public getUriString() : string
Return values
string

getVersion()

Return the HTTP version for this request

public getVersion() : string
Return values
string

isConnect()

Is this a CONNECT method request?

public isConnect() : bool
Return values
bool

isDelete()

Is this a DELETE method request?

public isDelete() : bool
Return values
bool

isFlashRequest()

Is this a Flash request?

public isFlashRequest() : bool
Return values
bool

isGet()

Is this a GET method request?

public isGet() : bool
Return values
bool

isHead()

Is this a HEAD method request?

public isHead() : bool
Return values
bool

isOptions()

Is this an OPTIONS method request?

public isOptions() : bool
Return values
bool

isPatch()

Is this a PATCH method request?

public isPatch() : bool
Return values
bool

isPost()

Is this a POST method request?

public isPost() : bool
Return values
bool

isPropFind()

Is this a PROPFIND method request?

public isPropFind() : bool
Return values
bool

isPut()

Is this a PUT method request?

public isPut() : bool
Return values
bool

isTrace()

Is this a TRACE method request?

public isTrace() : bool
Return values
bool

isXmlHttpRequest()

Is the request a Javascript XMLHttpRequest?

public isXmlHttpRequest() : bool

Should work with Prototype/Script.aculo.us, possibly others.

Return values
bool

renderRequestLine()

Return the formatted request line (first line) for this http request

public renderRequestLine() : string
Return values
string

setAllowCustomMethods()

public setAllowCustomMethods(bool $strictMethods) : mixed
Parameters
$strictMethods : bool

setBasePath()

Set the base path.

public setBasePath(string $basePath) : $this
Parameters
$basePath : string
Return values
$this

setBaseUrl()

Set the base URL.

public setBaseUrl(string $baseUrl) : $this
Parameters
$baseUrl : string
Return values
$this

setContent()

Set message content

public setContent(mixed $value) : Message
Parameters
$value : mixed
Return values
Message

setCookies()

Set cookies

public setCookies(string|array<string, string> $cookie) : $this

Instantiate and set cookies.

Parameters
$cookie : string|array<string, string>
Return values
$this

setEnv()

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
$this

setFiles()

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
$this

setHeaders()

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
see
getHeaders()
Return values
$this

setMetadata()

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
throws
InvalidArgumentException
Return values
Message

setMethod()

Set the method for this request

public setMethod(string $method) : $this
Parameters
$method : string
Tags
throws
InvalidArgumentException
Return values
$this

setPost()

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
$this

setQuery()

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
$this

setRequestUri()

Set the request URI.

public setRequestUri(string $requestUri) : $this
Parameters
$requestUri : string
Return values
$this

setServer()

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
$this

setUri()

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
throws
InvalidArgumentException
Return values
$this

setVersion()

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
throws
InvalidArgumentException
Return values
$this

toString()

public toString() : string
Return values
string

detectBasePath()

Autodetect the base path of the request

protected detectBasePath() : string

Uses several criteria to determine the base path of the request.

Return values
string

detectBaseUrl()

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
string

detectRequestUri()

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
string

mapPhpFileParam()

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>
Return values
array<string|int, mixed>

        
On this page

Search results