aResponse
MMO\core\classes · 1 symbol · generated 30 Sep 2026
aResponse
aResponse.php:16Base implementation of PSR-7's ResponseInterface (Response extends this): status code/reason phrase, plus convenience helpers for common response shapes (redirects, HTTP auth challenges).
- Namespace
MMO\core\classes- Extends
- aMessage
- Implements
- iResponse
- Uses traits
- tStoppableEvent
Index
| statusCode | ||
| statusText | ||
| stopped | ||
| debugName() | ||
| getExitCode() | ||
| getReasonPhrase() | Gets the response reason phrase associated with the status code. | |
| getRedirect() | ||
| getStatusCode() | Gets the response status code. | |
| isOk() | ||
| isPropagationStopped() | ||
| setRedirect($url, $status) | Set a redirection call send() to actually redirect | |
| setRequireAuth($realm, $type) | Set redirection to a login/password inputbox call send() to actually redirect | |
| setStatus($code, $reason) | ||
| stopPropagation() | Prevent any remaining listener in the current dispatch chain from being called. | |
| withRedirect($url, $status) | Set a redirection of a clone call send() to actually redirect | |
| withRequireAuth($realm, $type) | Set redirection to a login/password inputbox of a clone call send() to actually redirect | |
| withStatus($code, $reasonPhrase) | Return an instance with the specified status code and, optionally, reason phrase. | |
| __clone() | A cloned event starts fresh: propagation is never considered stopped on the clone, even if it was on the original instance. | |
| __construct($code, $reason, $headers) | ||
| __toString() |
Properties3
statusCode
- Type
- int
statusText
- Type
- string
stopped
Methods17
debugName()
aResponse.php:38| returns | string | e.g. '(Response)404: Not Found' |
getExitCode()
aResponse.php:59| returns | int | the CLI process exit code conventionally associated with this response's status code (e.g. for a shell command's response) |
getReasonPhrase()
aResponse.php:181Gets the response reason phrase associated with the status code.
| returns | string | Reason phrase; must return an empty string if none present. |
getRedirect()
aResponse.php:72getStatusCode()
aResponse.php:136Gets the response status code.
| returns | int | Status code. |
isOk()
aResponse.php:64| returns | bool | true if the status code represents success (2xx) |
isPropagationStopped()
tStoppableEvent.php:21| returns | bool | true once stopPropagation has been called on this instance |
setRedirect($url, $status)
aResponse.php:84Set a redirection call send() to actually redirect
| $url | the url to redirect to | |
| $status = 302 | status code | |
| returns | self | $this, for chaining |
setRequireAuth($realm, $type)
aResponse.php:108Set redirection to a login/password inputbox call send() to actually redirect
setStatus($code, $reason)
aResponse.php:47| $code | int | |
| $reason = '' | string | if empty, derived from $code via statusMessage |
| returns | self | $this, for chaining |
stopPropagation()
tStoppableEvent.php:29Prevent any remaining listener in the current dispatch chain from being called.
| returns |
withRedirect($url, $status)
aResponse.php:97Set a redirection of a clone call send() to actually redirect
withRequireAuth($realm, $type)
aResponse.php:121Set redirection to a login/password inputbox of a clone call send() to actually redirect
| $realm | string | random string |
| $type = 'Digest' | string | the WWW-Authenticate scheme, e.g. 'Digest' (default) or 'Basic' |
| returns | self |
withStatus($code, $reasonPhrase)
aResponse.php:162Return an instance with the specified status code and, optionally, reason phrase.
| $code | int | The 3-digit integer result code to set. |
| $reasonPhrase = '' | string | The reason phrase to use with the provided status code; if none is provided, implementations MAY use the defaults as suggested in the HTTP specification. |
| returns | self | |
| throws | For invalid status code arguments. |
__clone()
tStoppableEvent.php:38A cloned event starts fresh: propagation is never considered stopped on the clone, even if it was on the original instance.
| returns |
__construct($code, $reason, $headers)
aResponse.php:27| $code = 200 | int | Response code |
| $reason = '' | string | Status text -- if empty, defaults to the standard reason for $code (statusMessage) |
| $headers = [] | array | headers |
__toString()
aResponse.php:33| returns | string | the rendered response body, via the subclass's own render() implementation |
Inherited members (51)
| 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. | |
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. | |
getBody() | MessageInterface | Gets the body of the message. | |
getCharset() | aMessage | ||
getContentExtension() | aMessage | ||
getContentType($single) | aMessage | ||
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. | |
getParsedBody() | aMessage | ||
getProtocolVersion() | aMessage | Retrieves the HTTP protocol version as a string. | |
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 | ||
isWindows() | aMessage | ||
lock() | iResponse | ||
logEvent($event) | iResponse | ||
RemoveListener($handler) | aMessage | Remove the last added handler from the listeners. | |
render($opts) | iRenderable | ||
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). | |
unsetHeader($name) | aMessage | Remove a header entirely. | |
withAddedHeader($name, $value) | aMessage | Return an instance with the specified header appended with the given value. | |
withBody($body) | MessageInterface | Return an instance with the specified message body. | |
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. | |
withParsedBody($data) | aMessage | ||
withProtocolVersion($version) | aMessage | Return an instance with the specified HTTP protocol version. |