OutputCapture
MMO\core\helpers · 1 symbol · generated 5 Oct 2026
OutputCapture
OutputCapture.php:16Capture everything echoed/printed (via PHP's own output buffering, ob_start()) so it can be inspected, filtered, or discarded instead of being sent to the real output. Captures can nest: starting a new one suspends the previous one (its output is unaffected until the new one is closed).
- Namespace
MMO\core\helpers- Implements
- iRenderable
Index
| CHUNK_SIZE | ||
| active | ||
| chunks | ||
| filters | ||
| INSTS static | ||
| stream | ||
| streamStart | ||
| addFilter($filter) | Add a filter to apply to the text | |
| clear($end) | Clear output buffer | |
| close($clear) | Close the output buffer | |
| flush($end) | Flush output buffer and triggers all the filters for the resulted data | |
| getStream() | ||
| getText() | ||
| isActive() | ||
| IsCapturing() static | ||
| isCurrent() | ||
| makeCurrent($clean) | Ensure this capture is isCurrent, flushing/discarding (per $clean) any output buffer that was pushed on top of it in the meantime (logging a warning each time, since that's usually a sign of u… | |
| onWrite($buffer, $phase) | ||
| render($opts) | ||
| Start($stream, $chunkSize) static | Start capturing output. | |
| StartBig($chunkSize) static | Like Start, but always backed by a php://temp stream (spills to disk once large enough) instead of an in-memory array -- for output that may be too big to comfortably hold in memory. | |
| Stop() static | Close and return the most recently started (still active) capture. | |
| StopAll() static | Close every currently active capture, innermost first. | |
| __construct($stream, $chunkSize) | protected constructor so you cannot do new OutputCapture() -- use Start / StartBig | |
| __toString() |
Constants1
CHUNK_SIZE
Properties6
active
- Type
- bool
chunks
- Type
- array
filters
- Type
- array
INSTS
static- Type
- array
stream
streamStart
- Type
- int
Methods18
addFilter($filter)
OutputCapture.php:112Add a filter to apply to the text
| $filter | callable | function(string $buffer, int $phase, self $output): string|false. Returning false discards that chunk entirely. |
| returns | void |
clear($end)
OutputCapture.php:186Clear output buffer
close($clear)
OutputCapture.php:198Close the output buffer
| $clear = false | bool | if true, ignore content in the buffer |
| returns | string | the captured text (empty if $clear was true) |
flush($end)
OutputCapture.php:169Flush output buffer and triggers all the filters for the resulted data
getStream()
OutputCapture.php:117getText()
OutputCapture.php:125| returns | string | the text captured so far -- still readable after close (the final text is snapshotted then) |
isActive()
OutputCapture.php:130IsCapturing()
staticOutputCapture.php:79| returns | bool | true if at least one capture is currently active |
isCurrent()
OutputCapture.php:138| returns | bool | true if this capture is active AND is the innermost (most recently started, not yet closed) one -- i.e. it is the one PHP's output buffer stack is actually writing into right now |
makeCurrent($clean)
OutputCapture.php:150Ensure this capture is isCurrent, flushing/discarding (per $clean) any output buffer that was pushed on top of it in the meantime (logging a warning each time, since that's usually a sign of unrelated code calling ob_start() without cleaning up).
onWrite($buffer, $phase)
OutputCapture.php:217render($opts)
OutputCapture.php:95Start($stream, $chunkSize)
staticOutputCapture.php:39Start capturing output.
- See
StartBig) for potentially large output
| $stream = null | if given, captured text is written to this stream (or a stream opened from this filename) instead of being buffered in memory -- use this (or | |
| $chunkSize = self::CHUNK_SIZE | int | passed to ob_start()'s own chunk size |
| returns | self | the new, active capture |
StartBig($chunkSize)
staticOutputCapture.php:50Like Start, but always backed by a php://temp stream (spills to disk once large enough) instead of an in-memory array -- for output that may be too big to comfortably hold in memory.
Stop()
staticOutputCapture.php:60Close and return the most recently started (still active) capture.
| returns | self | the closed capture (its final text is available via getText) |
| throws | if no capture is currently active |
StopAll()
staticOutputCapture.php:72Close every currently active capture, innermost first.
| returns | void |
__construct($stream, $chunkSize)
OutputCapture.php:88protected constructor so you cannot do new OutputCapture() -- use Start / StartBig
| $stream = null | ||
| $chunkSize = self::CHUNK_SIZE | int |