ServerRequestFactory
in package
implements
ServerRequestFactoryInterface
Class for marshaling a request object from the current PHP environment.
Table of Contents
Interfaces
Properties
- $apacheRequestHeaders : callable
- Function to use to get apache request headers; present only to simplify mocking.
Methods
- createServerRequest() : ServerRequestInterface
- Create a new server request.
- fromGlobals() : ServerRequest
- Create a request from the supplied superglobal values.
Properties
$apacheRequestHeaders
Function to use to get apache request headers; present only to simplify mocking.
private
static callable
$apacheRequestHeaders
= 'apache_request_headers'
Methods
createServerRequest()
Create a new server request.
public
createServerRequest(string $method, mixed $uri[, array<string|int, mixed> $serverParams = [] ]) : ServerRequestInterface
Parameters
- $method : string
-
The HTTP method associated with the request.
- $uri : mixed
-
The URI associated with the request. If the value is a string, the factory MUST create a UriInterface instance based on it.
- $serverParams : array<string|int, mixed> = []
-
Array of SAPI parameters with which to seed the generated request instance.
Return values
ServerRequestInterfacefromGlobals()
Create a request from the supplied superglobal values.
public
static fromGlobals([array<string|int, mixed> $server = null ][, array<string|int, mixed> $query = null ][, array<string|int, mixed> $body = null ][, array<string|int, mixed> $cookies = null ][, array<string|int, mixed> $files = null ][, null|FilterServerRequestInterface $requestFilter = null ]) : ServerRequest
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
- $server : array<string|int, mixed> = null
-
$_SERVER superglobal
- $query : array<string|int, mixed> = null
-
$_GET superglobal
- $body : array<string|int, mixed> = null
-
$_POST superglobal
- $cookies : array<string|int, mixed> = null
-
$_COOKIE superglobal
- $files : array<string|int, mixed> = null
-
$_FILES superglobal
- $requestFilter : null|FilterServerRequestInterface = null
-
If present, the generated request will be passed to this instance and the result returned by this method. When not present, a default instance of FilterUsingXForwardedHeaders is created, using the
trustReservedSubnets()
constructor.