\Zend\DiactorosServerRequestFactory

Class for marshaling a request object from the current PHP environment.

Logic largely refactored from the ZF2 Zend\Http\PhpEnvironment\Request class.

Summary

Methods
Properties
Constants
fromGlobals()
get()
getHeader()
normalizeServer()
normalizeFiles()
marshalHeaders()
marshalUriFromServer()
marshalHostAndPortFromHeaders()
marshalRequestUri()
stripQueryString()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$apacheRequestHeaders
N/A

Properties

$apacheRequestHeaders

$apacheRequestHeaders : callable

Function to use to get apache request headers; present only to simplify mocking.

Type

callable

Methods

fromGlobals()

fromGlobals(array  $server = null, array  $query = null, array  $body = null, array  $cookies = null, array  $files = null) : \Zend\Diactoros\ServerRequest

Create a request from the supplied superglobal values.

If any argument is not supplied, the corresponding superglobal value will be used.

The ServerRequest created is then passed to the fromServer() method in order to marshal the request URI and headers.

Parameters

array $server

$_SERVER superglobal

array $query

$_GET superglobal

array $body

$_POST superglobal

array $cookies

$_COOKIE superglobal

array $files

$_FILES superglobal

Throws

\InvalidArgumentException

for invalid file values

Returns

\Zend\Diactoros\ServerRequest

get()

get(string  $key, array  $values, mixed  $default = null) : mixed

Access a value in an array, returning a default value if not found

Parameters

string $key
array $values
mixed $default

Returns

mixed

getHeader()

getHeader(string  $header, array  $headers, mixed  $default = null) : string

Search for a header value.

Does a case-insensitive search for a matching header.

If found, it is returned as a string, using comma concatenation.

If not, the $default is returned.

Parameters

string $header
array $headers
mixed $default

Returns

string

normalizeServer()

normalizeServer(array  $server) : array

Marshal the $_SERVER array

Pre-processes and returns the $_SERVER superglobal.

Parameters

array $server

Returns

array

normalizeFiles()

normalizeFiles(array  $files) : array

Normalize uploaded files

Transforms each value into an UploadedFileInterface instance, and ensures that nested arrays are normalized.

Parameters

array $files

Throws

\InvalidArgumentException

for unrecognized values

Returns

array

marshalHeaders()

marshalHeaders(array  $server) : array

Marshal headers from $_SERVER

Parameters

array $server

Returns

array

marshalUriFromServer()

marshalUriFromServer(array  $server, array  $headers) : \Zend\Diactoros\Uri

Marshal the URI from the $_SERVER array and headers

Parameters

array $server
array $headers

Returns

\Zend\Diactoros\Uri

marshalHostAndPortFromHeaders()

marshalHostAndPortFromHeaders(\stdClass  $accumulator, array  $server, array  $headers) 

Marshal the host and port from HTTP headers and/or the PHP environment

Parameters

\stdClass $accumulator
array $server
array $headers

marshalRequestUri()

marshalRequestUri(array  $server) : string

Detect the base URI for the request

Looks at a variety of criteria in order to attempt to autodetect a base URI, including rewrite URIs, proxy URIs, etc.

Parameters

array $server

Returns

string

stripQueryString()

stripQueryString(mixed  $path) : string

Strip the query string from a path

Parameters

mixed $path

Returns

string