# Writer

A Writer writes strings to some context. WriterInterface describe the interface for a component in charge of writing.

# Writers Container

WritersInterface describes a service container providing access to out, error, debug and log writers.

🧔🏾 Writers are intended to be used for providing multi-channel output

use Chevere\Components\Writer\Writers;

$writers = new Writers;

🧞 By default, it populates out and error to two different temp streams`.

Methods withOut, withError, withDebug and withLog can be used to specify each writer.

In the example below, the withDebug method is used to pass a stream writer for /var/debug_output file.

use Chevere\Components\Writer\StreamWriter;
use function Chevere\Components\Writer\streamFor;

$writers = $writers
        new StreamWriter(
            streamFor('/var/debug_output', 'w')

# Concrete Writers

# StreamWriter

The Chevere\Components\Writer\StreamWriter is a writer that writes to a stream.

Code below shows how to initiate a StreamWriter for a given string.

use Chevere\Components\Writer\StreamWriter;
use function Chevere\Components\Writer\streamForString;

$stream = streamForString('given string');
$writer = new StreamWriter($stream);
$writer->write('write some');