\Symfony\Component\Console\OutputConsoleSectionOutput

StreamOutput writes the output to a given stream.

Usage:

$output = new StreamOutput(fopen('php://stdout', 'w'));

As StreamOutput can use any stream, you can also use a file:

$output = new StreamOutput(fopen('/path/to/output.log', 'a', false));

Summary

Methods
Properties
Constants
__construct()
getStream()
clear()
overwrite()
getContent()
No public properties found
No constants found
doWrite()
hasColorSupport()
No protected properties found
N/A
popStreamContentUntilCurrentSection()
getDisplayLength()
$stream
$content
$lines
$sections
$terminal
N/A

Properties

$stream

$stream : 

Type

$content

$content : 

Type

$lines

$lines : 

Type

$sections

$sections : 

Type

$terminal

$terminal : 

Type

Methods

__construct()

__construct(resource  $stream, array<mixed,\Symfony\Component\Console\Output\ConsoleSectionOutput>  $sections, \Symfony\Component\Console\Output\int  $verbosity, \Symfony\Component\Console\Output\bool  $decorated, \Symfony\Component\Console\Formatter\OutputFormatterInterface  $formatter) 

Parameters

resource $stream

A stream resource

array<mixed,\Symfony\Component\Console\Output\ConsoleSectionOutput> $sections
\Symfony\Component\Console\Output\int $verbosity

The verbosity level (one of the VERBOSITY constants in OutputInterface)

\Symfony\Component\Console\Output\bool $decorated

Whether to decorate messages (null for auto-guessing)

\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter

Output formatter instance (null to use default OutputFormatter)

getStream()

getStream() : resource

Gets the stream attached to this StreamOutput instance.

Returns

resource —

A stream resource

clear()

clear(integer  $lines = null) 

Clears previous output for this section.

Parameters

integer $lines

Number of lines to clear. If null, then the entire output of this section is cleared

overwrite()

overwrite(array|string  $message) 

Overwrites the previous output with a new message.

Parameters

array|string $message

getContent()

getContent() 

doWrite()

doWrite(  $message,   $newline) 

{@inheritdoc}

Parameters

$message
$newline

hasColorSupport()

hasColorSupport() : boolean

Returns true if the stream supports colorization.

Colorization is disabled if not supported by the stream:

This is tricky on Windows, because Cygwin, Msys2 etc emulate pseudo terminals via named pipes, so we can only check the environment.

Reference: Composer\XdebugHandler\Process::supportsColor https://github.com/composer/xdebug-handler

Returns

boolean —

true if the stream supports colorization, false otherwise

popStreamContentUntilCurrentSection()

popStreamContentUntilCurrentSection(\Symfony\Component\Console\Output\int  $numberOfLinesToClearFromCurrentSection) 

At initial stage, cursor is at the end of stream output. This method makes cursor crawl upwards until it hits current section. Then it erases content it crawled through. Optionally, it erases part of current section too.

Parameters

\Symfony\Component\Console\Output\int $numberOfLinesToClearFromCurrentSection

getDisplayLength()

getDisplayLength(\Symfony\Component\Console\Output\string  $text) 

Parameters

\Symfony\Component\Console\Output\string $text