Index

ShellRequest

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

class

ShellRequest

ShellRequest.php:102

Command Request used to create a simple request from a string Models a CLI invocation as a PSR-7-style Request: the script's own path becomes the URI, and the rest of $argv becomes the body (ShellArguments) -- lets CLI scripts and controllers reuse the same Request/Response machinery as HTTP requests.

class MMO\core\server\ShellRequest extends MMO\core\classes\aRequest
Namespace
MMO\core\server
Extends
aRequest
// $argv = ['script.php', '-x', '--name=bar'] $req = ShellRequest::Server(); $req->getMethod(); // 'SHELL' $req->getBody(); // Stream wrapping '-x --name=bar'

Methods14

getBody()

ShellRequest.php:190
function getBody(): Psr\Http\Message\StreamInterface
returnsStreamInterfacethe arguments (ShellArguments), re-serialized into a shell argument string stream.

getCookieParams()

ShellRequest.php:168
function getCookieParams(): array
returnsarrayalways [] -- a shell command has no cookies.

getQueryParams()

ShellRequest.php:158
function getQueryParams(): array
returnsarrayalways [] -- a shell command has no query string; its arguments live in the body (getBody).

getUploadedFiles()

ShellRequest.php:178
function getUploadedFiles(): array
returnsarrayalways [] -- a shell command has no uploaded files.

jsonSerialize()

ShellRequest.php:137
function jsonSerialize(): array
returnsarray['method' => 'SHELL', 'url' => ..., 'body' => the ShellArguments].

Server()

staticShellRequest.php:104
static function Server(): self
returnsselfbuilt from the real process's $argv (script path as the URI, remaining args as the body) and $_SERVER.

withBody($body)

ShellRequest.php:198
function withBody(Psr\Http\Message\StreamInterface $body): self
$bodyStreamInterfacea stream whose content is a shell argument string (parse).
returnsselfa clone with the body replaced by the parsed arguments.

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

ShellRequest.php:119
function __construct( string $uri, array|string $body = '', array $headers = [], array $cookie = [], array $files = [] )
$uristringthe (file://) URI identifying the command, typically the script's own path.
$body = ''array | stringthe command-line arguments (a shell string, or a token list e.g. from $argv).
$headers = []arrayunused (kept for signature parity with other aRequest subclasses).
$cookie = []arrayunused.
$files = []arrayunused.

__toString()

ShellRequest.php:131
function __toString(): string
returnsstringthe URI followed by the re-serialized arguments (e.g. 'file:///script.php -x --name=bar').
Inherited members (64)
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