SSHStream
MMO\core\server · 1 symbol · generated 5 Oct 2026
SSHStream
SSHStream.php:12A Stream wrapping the stdout of a command started via SSH::openExec, with the matching stderr stream and exit code alongside it.
- Namespace
MMO\core\server- Extends
- Stream
Index
| exitCode | ||
| ssh readonly | ||
| stderr | ||
| close() | Close both the stdout (Stream::close) and, if fetched, the stderr stream. | |
| getContents($errors) | Read the output of the ssh command (and its errors) NOTE: when $errors is passed, the two streams are drained TOGETHER (loopContentsAsync), not one after the other. | |
| getExitCode() | ||
| getStderr() | Get the stderr resource | |
| loopContentsAsync($stdout, $stderr) | Read content asynchronously using a Generator. | |
| __construct($ssh, $stream) |
Properties3
exitCode
ssh
readonly- Type
- SSH
stderr
Methods6
close()
SSHStream.php:36Close both the stdout (Stream::close) and, if fetched, the stderr stream.
| returns | void |
getContents($errors)
SSHStream.php:78Read the output of the ssh command (and its errors) NOTE: when $errors is passed, the two streams are drained TOGETHER (loopContentsAsync), not one after the other. It used to read stderr to completion first and stdout afterwards, both blocking, which deadlocks as soon as a command fills the buffer of the stream that isn't being read: the remote process blocks writing to stdout while this side waits forever on stderr. Since SSH::execSafe always passes $errors, that was reachable from a plain $ssh->exec() on any chatty command.
| $errors = null | null | string | filled with stderr's content -- only read at all if this parameter is actually passed (checked via func_num_args(), so even explicitly passing null triggers it; SSH::execSafe always passes it). |
| returns | string |
getExitCode()
SSHStream.php:50| returns | null | int | the command's exit code, or null until it's known -- the ssh2 extension only exposes it (as exit_status stream metadata) once the stream has been fully read (eof), so this always returns null until stdout has been drained (getContents/loopContentsAsync). |
getStderr()
SSHStream.php:59Get the stderr resource
| returns | null if the underlying stdout stream is already detached/closed. |
loopContentsAsync($stdout, $stderr)
SSHStream.php:108Read content asynchronously using a Generator.
__construct($ssh, $stream)
SSHStream.php:24| $ssh | SSH | |
| $stream | the command's stdout stream (as returned by ssh2_exec()). |
Inherited members (29)
| Properties | Declared by | Description | |
|---|---|---|---|
stream | Stream |
| Methods | Declared by | Description | |
|---|---|---|---|
debugName() | Stream | ||
detach() | Stream | StreamInterface::detach | |
Empty() | Stream | Get an empty stream WARNING: don't write in it as this instance is shared by whomever call this function | |
eof() | Stream | StreamInterface::eof | |
File($filename, $mode) | Stream | Get a Stream on a file | |
getContentType($single) | Stream | NOTE: the return type used to be declared string|array even though this method can return false (when the stream has no usable URI) -- harmless in practice (PHP's weak typing silently coerces t… | |
getMetadata($key) | Stream | StreamInterface::getMetadata | |
getResource() | Stream | ||
getSize() | Stream | StreamInterface::getSize | |
getUri() | Stream | ||
isReadable() | Stream | StreamInterface::isReadable | |
isSeekable() | Stream | StreamInterface::isSeekable | |
isWritable() | Stream | StreamInterface::isWritable | |
read($length) | Stream | StreamInterface::read | |
render($opts) | Stream | ||
rewind() | Stream | StreamInterface::rewind Shorthand for seek(0). | |
seek($offset, $whence) | Stream | StreamInterface::seek | |
serialize($path, $serializer) | Stream | ||
STDERR() | Stream | ||
STDIN() | Stream | ||
STDOUT() | Stream | ||
tell() | Stream | StreamInterface::tell | |
TEMP() | Stream | Get a new stream backed by php://temp (memory, spilling to a temp file past ~2MB -- unlike Text, which is always pure memory). | |
Text($text) | Stream | Get a Stream on a text | |
unserialize($data, $path, $instances) | Stream | ||
write($text) | Stream | StreamInterface::write Writes the full string, looping over fwrite (which can write fewer bytes than requested in one call, e.g. | |
__destruct() | Stream | Destructor. Closes the stream | |
__toString() | Stream | StreamInterface::__toString |