ServerRequestFactory implements ServerRequestFactoryInterface
Class ServerRequestFactory to create ServerRequest objects
Highly inspired by https://github.com/phly/http/
Note that this is not public API yet.
Table of Contents
Interfaces
- ServerRequestFactoryInterface
Methods
- createServerRequest() : ServerRequestInterface
- Create a new server request.
- fromGlobals() : ServerRequest
- Create a request from the original superglobal variables.
- createUploadedFile() : UploadedFileInterface[]|UploadedFileInterface|null
- Create and return an UploadedFile instance from a $_FILES specification.
- normalizeUploadedFiles() : array
- Normalize uploaded files
- prepareHeaders() : array
- Fetch headers from $_SERVER variables which are only the ones starting with HTTP_* and CONTENT_*
Methods
createServerRequest()
Create a new server request.
public
createServerRequest(string $method, UriInterface|string $uri[, array $serverParams = [] ]) : ServerRequestInterface
Note that server-params are taken precisely as given - no parsing/processing of the given values is performed, and, in particular, no attempt is made to determine the HTTP method or URI, which must be provided explicitly.
Parameters
- $method : string
-
The HTTP method associated with the request.
- $uri : UriInterface|string
-
The URI associated with the request.
- $serverParams : array = []
-
Array of SAPI parameters with which to seed the generated request instance.
Return values
ServerRequestInterfacefromGlobals()
Create a request from the original superglobal variables.
public
static fromGlobals() : ServerRequest
Note that this is not public API yet.
Tags
Return values
ServerRequestcreateUploadedFile()
Create and return an UploadedFile instance from a $_FILES specification.
protected
static createUploadedFile(array $value) : UploadedFileInterface[]|UploadedFileInterface|null
If the specification represents an array of values, this method will recursively resolve uploaded files.
Parameters
- $value : array
-
$_FILES structure
Return values
UploadedFileInterface[]|UploadedFileInterface|nullnormalizeUploadedFiles()
Normalize uploaded files
protected
static normalizeUploadedFiles(array $files) : array
Transforms each value into an UploadedFileInterface instance, and ensures that nested arrays are normalized.
Parameters
- $files : array
Tags
Return values
arrayprepareHeaders()
Fetch headers from $_SERVER variables which are only the ones starting with HTTP_* and CONTENT_*
protected
static prepareHeaders(array $server) : array
Parameters
- $server : array