Index

Request

MMO\core\server · 1 symbol · generated 5 Oct 2026

class

Request

Request.php:17

PSR-7-style HTTP request.

class MMO\core\server\Request extends MMO\core\classes\aRequest
Namespace
MMO\core\server
Extends
aRequest
$req = new Request('POST', 'https://example.com/foo?x=1', ['name' => 'bar']); $req->getMethod(); // 'POST' $req->getQueryParams(); // ['x' => '1'] $req2 = $req->withQueryParams(['x' => '2']); // returns a new instance; $req is unchanged

Index

UPLOAD_MESSAGES
cookie
files
method
getBody()
getCookieParams()Retrieve cookies.
getMethod()
getQueryParams()Retrieve query string arguments.
getUploadedFiles()Retrieve normalized file upload data.
jsonSerialize()
Server() staticBuild a Request from the current real HTTP request ($_SERVER, $_FILES, $_COOKIE, and the raw request body/$_POST), normalizing the Authorization header across the various ways different SAP…
setUploadedFiles($files)
withBody($body)
withCookieParams($cookies)Return an instance with the specified cookies.
withMethod($method)
withQueryParams($query)Return an instance with the specified query string arguments.
withUploadedFiles($uploadedFiles)Create a new instance with the specified uploaded files.
__construct($method, $uri, $body, $headers, $cookie, $files)

Constants1

UPLOAD_MESSAGES

const UPLOAD_MESSAGES = […8 items]
See
setUploadedFiles -- human-readable text for each UPLOAD_ERR_* code.

Properties3

files

protected array $files
Type
array

method

protected string $method
Type
string

Methods14

getBody()

Request.php:98
function getBody(): Psr\Http\Message\StreamInterface
returnsStreamInterfacethe body, re-serialized as a key=value&... query string.

getCookieParams()

Request.php:172

Retrieve cookies.

function getCookieParams(): arrayRetrieves cookies sent by the client to the server. The data MUST be compatible with the structure of the $_COOKIE superglobal.
returnsarray

getMethod()

Request.php:70
function getMethod(): string
returnsstringthe HTTP method, uppercase (e.g. 'GET').

getQueryParams()

Request.php:130

Retrieve query string arguments.

function getQueryParams(): arrayRetrieves the deserialized query string arguments, if any. Note: the query params might not be in sync with the URI or server params. If you need to ensure you are only getting the original values, you may need to parse the query string from `getUri()->getQuery()` or from the `QUERY_STRING` server param.
returnsarray

getUploadedFiles()

Request.php:211

Retrieve normalized file upload data.

function getUploadedFiles(): arrayThis method returns upload metadata in a normalized tree, with each leaf an instance of Psr\Http\Message\UploadedFileInterface. These values MAY be prepared from $_FILES or the message body during instantiation, or MAY be injected via withUploadedFiles().
returnsarrayAn array tree of UploadedFileInterface instances; an empty array MUST be returned if no data is present.

jsonSerialize()

Request.php:51
function jsonSerialize(): mixed
returnsmixed['method' => ..., 'url' => ...] plus 'body'/'attributes'/'cookie'/'files' whenever they're non-empty.

Server()

staticRequest.php:255

Build a Request from the current real HTTP request ($_SERVER, $_FILES, $_COOKIE, and the raw request body/$_POST), normalizing the Authorization header across the various ways different SAPIs/proxies expose it, and decoding the body per its Content-Type (form-encoded, JSON, or raw).

static function Server(): selfIts headers are kept under their own names (`$_SERVER['HTTP_X_CSRF_TOKEN']` is `X-Csrf-Token`, [`HeaderName`](https://mcp.mmoframework.fr/documentation/mmo.core/php/classes/aRequest.md#arequest-headername)), so `getHeaderLine('Range')` reads one; the rest of `$_SERVER` is kept as it is (`DOCUMENT_ROOT`).
returnsself
Request::Server()->getHeaderLine('If-None-Match'); // what `$_SERVER['HTTP_IF_NONE_MATCH']` has

setUploadedFiles($files)

Request.php:220
protected function setUploadedFiles(array $files): void
$filesarrayraw $_FILES-shaped entries (each with an 'error' key, an UPLOAD_ERR_* constant). Replaces $this->files entirely: a failed upload (error !== UPLOAD_ERR_OK) is stored as a \RuntimeException (UPLOAD_MESSAGES) instead of the raw file info, so callers can instanceof check it.
returnsvoid

withBody($body)

Request.php:106
function withBody(Psr\Http\Message\StreamInterface $body): self
$bodyStreamInterfacea stream whose content is a key=value&... query string.
returnsselfa clone with the body replaced by the parsed content.

withCookieParams($cookies)

Request.php:193

Return an instance with the specified cookies.

function withCookieParams(array $cookies): selfThe data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST be compatible with the structure of $_COOKIE. Typically, this data will be injected at instantiation. This method MUST NOT update the related Cookie header of the request instance, nor related values in the server params. This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated cookie values.
$cookiesarrayArray of key/value pairs representing cookies.
returnsself

withMethod($method)

Request.php:78
function withMethod(string $method): self
$methodstringcase-insensitive, normalized to uppercase.
returnsselfa clone with the new method.

withQueryParams($query)

Request.php:156

Return an instance with the specified query string arguments.

function withQueryParams(array $query): selfThese values SHOULD remain immutable over the course of the incoming request. They MAY be injected during instantiation, such as from PHP's $_GET superglobal, or MAY be derived from some other value such as the URI. In cases where the arguments are parsed from the URI, the data MUST be compatible with what PHP's parse_str() would return for purposes of how duplicate query parameters are handled, and how nested sets are handled. Setting query string arguments MUST NOT change the URI stored by the request, nor the values in the server params. This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated query string arguments.
$queryarrayArray of query string arguments, typically from $_GET.
returnsself

withUploadedFiles($uploadedFiles)

Request.php:238

Create a new instance with the specified uploaded files.

function withUploadedFiles(array $uploadedFiles): selfThis method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated body parameters.
$uploadedFilesarrayAn array tree of UploadedFileInterface instances.
returnsself
throwsif an invalid structure is provided.

__construct($method, $uri, $body, $headers, $cookie, $files)

Request.php:42
function __construct( string $method, $uri, array $body = [], array $headers = [], array $cookie = [], array $files = [] )
$methodstringthe HTTP method (case-insensitive, normalized to uppercase).
$uri
$body = []arraythe parsed request body (e.g. $_POST, or a decoded JSON payload).
$headers = []arrayby name, or as $_SERVER has them (HTTP_RANGE is kept as Range: HeaderName).
$cookie = []arraye.g. $_COOKIE.
$files = []arrayraw $_FILES-shaped upload entries (setUploadedFiles).
Inherited members (65)
PropertiesDeclared byDescription
attributesaRequest
bodyaRequest
headersaMessage
ikeysaMessage
ListenersaMessage
protocolaMessage
targetaRequest
uriaRequest
MethodsDeclared byDescription
addHeader($name, $value)aMessageAppend a value to a header, keeping any value(s) already set (as opposed to setHeader, which replaces).
AddListener($handler, $order)aMessageRegister a listener directly (as opposed to ConnectListeners's attribute-based discovery).
ConnectListeners($obj)aMessageScan $obj's methods for #[Listen(EventClass::class)] attributes and register each one as a listener on the matching event class.
debugName()aRequest
DisconnectListeners($obj)aMessageUndo a previous ConnectListeners: removes every listener that connect had registered for $obj on this event class.
dispatch()aMessageInvoke every GetListeners listener with $this.
getAttribute($name, $default)aRequestRetrieve a single derived request attribute.
getAttributes()aRequestRetrieve attributes derived from the request.
getCharset()aMessage
getContentExtension()aMessage
getContentType($single)aMessage
getHeader($name)aRequest
getHeaderLine($name)aMessageRetrieves a comma-separated string of the values for a single header.
getHeaders()aMessageRetrieves all message header values.
GetListeners()aMessageCollect every listener for this class, including those registered on its parent classes (so a subclass event is also caught by listeners of its parent event), sorted by ascending $order (ties keep …
getOrigin()aMessageGet origin of the request by looking at 'Origin', then 'Referer', then 'Sender' in the request's headers.
getParsedBody()aRequestRetrieve any parameters provided in the request body.
getProtocolVersion()aMessageRetrieves the HTTP protocol version as a string.
getRequestTarget()aRequestRetrieves the message's request target.
getServerParams()aRequestRetrieve server parameters.
getUri($mutable)aRequestRetrieves the URI instance.
getUserAgent()aMessage
hasHeader($name)aRequest
HasListener($handler)aMessage
HeaderName($name)aRequestThe name of the header php's $_SERVER calls $name -- the way a web server hands php a request's headers: HTTP_X_CSRF_TOKEN is X-Csrf-Token, CONTENT_TYPE is Content-Type.
isHTML()aMessage
isIe()aMessage
isIphone()aMessage
isJSON()aMessage
isMac()aMessage
isMobile()aMessage
isWindows()aMessage
RemoveListener($handler)aMessageRemove the last added handler from the listeners.
Send($args)aMessageConstruct a new instance of this class with $args, then dispatch it to every listener.
setCacheControl($cache, $pragma)aMessageSet the Cache-Control header (and, optionally, the legacy Pragma header alongside it).
setContentType($type, $charset)aMessageSet the Content-Type header, appending a charset parameter (unless $charset is null/empty).
setExpires($time)aMessageSet the Expires header from a unix timestamp, formatted as an RFC 7231 HTTP-date.
setHeader($name, $value)aRequest
SetListenerOrder($handler, $order)aMessageChange the order of an already-registered listener, whether added directly via AddListener or indirectly via ConnectListeners (which also stores its [$obj, $methodName] callables here).
setUri($uri, $preserveHost)aRequest
unsetHeader($name)aRequest
withAddedHeader($name, $value)aMessageReturn an instance with the specified header appended with the given value.
withAttribute($name, $value)aRequestReturn an instance with the specified derived request attribute.
withAttributes($attrs)aRequestReturn an instance with several derived request attributes set at once (merged via
withCacheControl($cache, $pragma)aMessageSet cache control of a clone.
withContentType($type, $charset)aMessageSet content type of a clone.
withExpires($time)aMessageSet cache expire date of a clone.
withHeader($name, $value)aMessageReturn an instance with the provided value replacing the specified header.
withHeaders($headers, $reset)aMessageReturn a clone with every header in $headers set (through tWithHeaders::setHeader, so each value replaces any existing one for the same header name).
withoutAttribute($name)aRequestReturn an instance that removes the specified derived request attribute.
withoutHeader($name)aMessageReturn an instance without the specified header.
withParsedBody($data)aRequestReturn an instance with the specified body parameters.
withProtocolVersion($version)aMessageReturn an instance with the specified HTTP protocol version.
withRequestTarget($requestTarget)aRequestReturn an instance with the specific request-target.
withUri($uri, $preserveHost)aRequestReturns an instance with the provided URI.
__clone()aRequest
__toString()aRequest