Response
MMO\core\server · 1 symbol · generated 30 Sep 2026
Response
Response.php:21Psr Response with a body as an object.
- Namespace
MMO\core\server- Extends
- aResponse
- Implements
- JsonSerializable
Index
| document | ||
| Csv($document, $status, $reason, $headers) static | Generate a Csv response with a plain Document (using CsvPrinter::Encode) as body | |
| FromMime($mime, $document, $status, $reason, $headers) static | Build a Response using the static factory matching a given mime type/extension (extension), passing $document through to it. | |
| getBody() | Gets the body of the message. | |
| getParsedBody() | Retrieve the response body. | |
| Html($document, $status, $reason, $headers) static | Generate an Html response with an HtmlDocument as body | |
| Json($document, $status, $reason, $headers) static | Generate a Json response with a JsonDocument as body | |
| jsonSerialize() | ||
| lock() | Mark the body document read-only (no further mutation allowed). | |
| logEvent($event) | ||
| Redirect($redirectUri, $headers, $post, $status, $reason) static | ||
| render($opts) | ||
| Shell($document, $status, $reason, $headers) static | Generate a Text response with a TextDocument as body, rendered via ShellPrinter (ANSI-colored output for terminals) instead of TextDocument's default plain-text printer. | |
| Text($document, $status, $reason, $headers) static | Generate a Text response with a TextDocument as body | |
| withBody($body) | Return an instance with the specified message body. | |
| withParsedBody($data) | ||
| Xlsx($document, $status, $reason, $headers) static | Generate an Xlsx (excel) response with a XlsxDocument as body | |
| Xml($document, $status, $reason, $headers) static | Generate an Xml response with an XmlDocument as body | |
| __construct($document, $status, $reason, $headers) | ||
| __toString() |
Properties1
document
- Type
- Document
Methods19
Csv($document, $status, $reason, $headers)
staticResponse.php:153Generate a Csv response with a plain Document (using CsvPrinter::Encode) as body
FromMime($mime, $document, $status, $reason, $headers)
staticResponse.php:118Build a Response using the static factory matching a given mime type/extension (extension), passing $document through to it.
- See
extensionresolves it, and only matches full mime-type strings).
| $mime | string | a mime type header value, e.g. 'application/json' (NOT a bare extension like 'json' -- |
| $document = null | Document | array | null | the body to use, appropriate to the resolved mime type (see NOTE above). |
| $status = 200 | int | |
| $reason = '' | string | |
| $headers = [] | array | |
| returns | self | |
| throws | if $mime resolves to 'xml'/'html' and $document is a plain array. |
getBody()
Response.php:233Gets the body of the message.
| returns | StreamInterface | Returns the body as a stream. |
getParsedBody()
Response.php:265Retrieve the response body.
| returns | Document | The deserialized body response, if any. These will typically be an array or object. |
Html($document, $status, $reason, $headers)
staticResponse.php:193Generate an Html response with an HtmlDocument as body
Json($document, $status, $reason, $headers)
staticResponse.php:139Generate a Json response with a JsonDocument as body
jsonSerialize()
Response.php:52| returns | mixed | the body document (its own jsonSerialize() then does the actual encoding). |
lock()
Response.php:66Mark the body document read-only (no further mutation allowed).
| returns | void |
logEvent($event)
Response.php:47| $event | object | |
| returns | bool | whether the document logged $event (delegates to Document::logEvent). |
Redirect($redirectUri, $headers, $post, $status, $reason)
staticResponse.php:83render($opts)
Response.php:61- See
iRenderable::render
Shell($document, $status, $reason, $headers)
staticResponse.php:180Generate a Text response with a TextDocument as body, rendered via ShellPrinter (ANSI-colored output for terminals) instead of TextDocument's default plain-text printer.
Text($document, $status, $reason, $headers)
staticResponse.php:166Generate a Text response with a TextDocument as body
withBody($body)
Response.php:250Return an instance with the specified message body.
| $body | StreamInterface | Body. |
| returns | ResponseInterface | |
| throws | When the body is not valid. |
withParsedBody($data)
Response.php:274| $data | ArrayAccess | array | null | replaces the response's document -- a plain array/\ArrayAccess is wrapped in a plain Document (losing whatever printer/type the previous document had). |
| returns | self | a clone with the new document. |
Xlsx($document, $status, $reason, $headers)
staticResponse.php:219Generate an Xlsx (excel) response with a XlsxDocument as body
Xml($document, $status, $reason, $headers)
staticResponse.php:206Generate an Xml response with an XmlDocument as body
__construct($document, $status, $reason, $headers)
Response.php:34| $document = null | ArrayAccess | array | null | the parsed body of the response -- a plain array/\ArrayAccess is wrapped in a plain Document; pass an already-built Document (e.g. from Json/Html/...) to control its type/printer instead. |
| $status = 200 | int | Response status |
| $reason = '' | string | Status text |
| $headers = [] | array | headers |
__toString()
Response.php:71Inherited members (62)
| Properties | Declared by | Description | |
|---|---|---|---|
headers | aMessage | ||
ikeys | aMessage | ||
Listeners | aMessage | ||
protocol | aMessage | ||
statusCode | aResponse | ||
statusText | aResponse | ||
stopped | aResponse |
| Methods | Declared by | Description | |
|---|---|---|---|
addHeader($name, $value) | aMessage | Append a value to a header, keeping any value(s) already set (as opposed to setHeader, which replaces). | |
AddListener($handler, $order) | aMessage | Register a listener directly (as opposed to ConnectListeners's attribute-based discovery). | |
ConnectListeners($obj) | aMessage | Scan $obj's methods for #[Listen(EventClass::class)] attributes and register each one as a listener on the matching event class. | |
debugName() | aResponse | ||
DisconnectListeners($obj) | aMessage | Undo a previous ConnectListeners: removes every listener that connect had registered for $obj on this event class. | |
dispatch() | aMessage | Invoke every GetListeners listener with $this. | |
getCharset() | aMessage | ||
getContentExtension() | aMessage | ||
getContentType($single) | aMessage | ||
getExitCode() | aResponse | ||
getHeader($name) | aMessage | Retrieves a message header value by the given case-insensitive name. | |
getHeaderLine($name) | aMessage | Retrieves a comma-separated string of the values for a single header. | |
getHeaders() | aMessage | Retrieves all message header values. | |
GetListeners() | aMessage | Collect 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() | aMessage | Get origin of the request by looking at 'Origin', then 'Referer', then 'Sender' in the request's headers. | |
getProtocolVersion() | aMessage | Retrieves the HTTP protocol version as a string. | |
getReasonPhrase() | aResponse | Gets the response reason phrase associated with the status code. | |
getRedirect() | aResponse | ||
getStatusCode() | aResponse | Gets the response status code. | |
getUserAgent() | aMessage | ||
hasHeader($name) | aMessage | Checks if a header exists by the given case-insensitive name. | |
HasListener($handler) | aMessage | ||
isHTML() | aMessage | ||
isIe() | aMessage | ||
isIphone() | aMessage | ||
isJSON() | aMessage | ||
isMac() | aMessage | ||
isMobile() | aMessage | ||
isOk() | aResponse | ||
isPropagationStopped() | aResponse | ||
isWindows() | aMessage | ||
RemoveListener($handler) | aMessage | Remove the last added handler from the listeners. | |
Send($args) | aMessage | Construct a new instance of this class with $args, then dispatch it to every listener. | |
setCacheControl($cache, $pragma) | aMessage | Set the Cache-Control header (and, optionally, the legacy Pragma header alongside it). | |
setContentType($type, $charset) | aMessage | Set the Content-Type header, appending a charset parameter (unless $charset is null/empty). | |
setExpires($time) | aMessage | Set the Expires header from a unix timestamp, formatted as an RFC 7231 HTTP-date. | |
setHeader($name, $value) | aMessage | Set header, replacing any previous value(s) for the same (case-insensitively matched) header name. | |
SetListenerOrder($handler, $order) | aMessage | Change the order of an already-registered listener, whether added directly via AddListener or indirectly via ConnectListeners (which also stores its [$obj, $methodName] callables here). | |
setRedirect($url, $status) | aResponse | Set a redirection call send() to actually redirect | |
setRequireAuth($realm, $type) | aResponse | Set redirection to a login/password inputbox call send() to actually redirect | |
setStatus($code, $reason) | aResponse | ||
stopPropagation() | aResponse | Prevent any remaining listener in the current dispatch chain from being called. | |
unsetHeader($name) | aMessage | Remove a header entirely. | |
withAddedHeader($name, $value) | aMessage | Return an instance with the specified header appended with the given value. | |
withCacheControl($cache, $pragma) | aMessage | Set cache control of a clone. | |
withContentType($type, $charset) | aMessage | Set content type of a clone. | |
withExpires($time) | aMessage | Set cache expire date of a clone. | |
withHeader($name, $value) | aMessage | Return an instance with the provided value replacing the specified header. | |
withHeaders($headers, $reset) | aMessage | Return a clone with every header in $headers set (through tWithHeaders::setHeader, so each value replaces any existing one for the same header name). | |
withoutHeader($name) | aMessage | Return an instance without the specified header. | |
withProtocolVersion($version) | aMessage | Return an instance with the specified HTTP protocol version. | |
withRedirect($url, $status) | aResponse | Set a redirection of a clone call send() to actually redirect | |
withRequireAuth($realm, $type) | aResponse | Set redirection to a login/password inputbox of a clone call send() to actually redirect | |
withStatus($code, $reasonPhrase) | aResponse | Return an instance with the specified status code and, optionally, reason phrase. | |
__clone() | aResponse | A cloned event starts fresh: propagation is never considered stopped on the clone, even if it was on the original instance. |