Class Symfony\Component\Console\Output\StreamOutput

InheritanceSymfony\Component\Console\Output\StreamOutput » Symfony\Component\Console\Output\Output
ImplementsSymfony\Component\Console\Output\OutputInterface
SubclassesSymfony\Component\Console\Output\ConsoleOutput

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));

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
doWrite() {@inheritdoc} Symfony\Component\Console\Output\StreamOutput
hasColorSupport() Returns true if the stream supports colorization. Symfony\Component\Console\Output\StreamOutput

Method Details

__construct() public method

Constructor.

public void __construct ( $stream, $verbosity self::VERBOSITY_NORMAL, $decorated null, Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter null )
$stream resource

A stream resource

$verbosity int

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

$decorated bool|null

Whether to decorate messages (null for auto-guessing)

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

Output formatter instance (null to use default OutputFormatter)

throws Symfony\Component\Console\Exception\InvalidArgumentException

When first argument is not a real stream

doWrite() protected method

{@inheritdoc}

protected void doWrite ( $message, $newline )
$message
$newline
getStream() public method

Gets the stream attached to this StreamOutput instance.

public resource getStream ( )
return resource

A stream resource

hasColorSupport() protected method

Returns true if the stream supports colorization.

Colorization is disabled if not supported by the stream:

  • Windows != 10.0.10586 without Ansicon, ConEmu or Mintty
  • non tty consoles
protected bool hasColorSupport ( )
return bool

True if the stream supports colorization, false otherwise