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
🧔🏾 Writers are intended to be used for providing multi-channel output
use Chevere\Components\Writer\Writers; $writers = new Writers;
🧞 By default, it populates
errorto two different temp streams`.
withLog can be used to specify each writer.
In the example below, the
withDebug method is used to pass a stream writer for
use Chevere\Components\Writer\StreamWriter; use function Chevere\Components\Writer\streamFor; $writers = $writers ->withDebug( new StreamWriter( streamFor('/var/debug_output', 'w') ) );
# Concrete Writers
Chevere\Components\Writer\StreamWriter is a writer that writes to a stream.
Code below shows how to initiate a
StreamWriter for a
use Chevere\Components\Writer\StreamWriter; use function Chevere\Components\Writer\streamForString; $stream = streamForString('given string'); $writer = new StreamWriter($stream); $writer->write('write some');