Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

(no description)

File Size: 344 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: ServerRequest  - X-Ref

Server-side HTTP request

Extends the Request definition to add methods for accessing incoming data,
specifically server parameters, cookies, matched path parameters, query
string arguments, body parameters, and upload file information.

"Attributes" are discovered via decomposing the request (and usually
specifically the URI path), and typically will be injected by the application.

Requests are considered immutable; all methods that might change state are
implemented such that they retain the internal state of the current
message and return a new instance that contains the changed state.
__construct(string $method,$uri,array $headers = [],$body = null,string $version = '1.1',array $serverParams = [])   X-Ref

param: string                               $method       HTTP method
param: string|UriInterface                  $uri          URI
param: array<string, string|string[]>       $headers      Request headers
param: string|resource|StreamInterface|null $body         Request body
param: string                               $version      Protocol version
param: array                                $serverParams Typically the $_SERVER superglobal

normalizeFiles(array $files)   X-Ref
Return an UploadedFile instance array.

param: array $files An array which respect $_FILES structure

createUploadedFileFromSpec(array $value)   X-Ref
Create and return an UploadedFile instance from a $_FILES specification.

If the specification represents an array of values, this method will
delegate to normalizeNestedFileSpec() and return that return value.

param: array $value $_FILES struct
return: UploadedFileInterface|UploadedFileInterface[]

normalizeNestedFileSpec(array $files = [])   X-Ref
Normalize an array of file specifications.

Loops through all nested files and returns a normalized array of
UploadedFileInterface instances.

return: UploadedFileInterface[]

fromGlobals()   X-Ref
Return a ServerRequest populated with superglobals:
$_GET
$_POST
$_COOKIE
$_FILES
$_SERVER


extractHostAndPortFromAuthority(string $authority)   X-Ref
No description

getUriFromGlobals()   X-Ref
Get a Uri populated with values from $_SERVER.


getServerParams()   X-Ref
No description

getUploadedFiles()   X-Ref
No description

withUploadedFiles(array $uploadedFiles)   X-Ref
No description

getCookieParams()   X-Ref
No description

withCookieParams(array $cookies)   X-Ref
No description

getQueryParams()   X-Ref
No description

withQueryParams(array $query)   X-Ref
No description

getParsedBody()   X-Ref
{@inheritdoc}

return: array|object|null

withParsedBody($data)   X-Ref
No description

getAttributes()   X-Ref
No description

getAttribute($attribute, $default = null)   X-Ref
{@inheritdoc}

return: mixed

withAttribute($attribute, $value)   X-Ref
No description

withoutAttribute($attribute)   X-Ref
No description