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
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\StreamWriterFromString; $writers = $writers ->withDebug( new StreamWriterFromString('/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
use Chevere\Components\Writer\StreamWriter; use Laminas\Diactoros\StreamFactory; $stream = (new StreamFactory)->createStream(''); $writer = new StreamWriter($stream); $writer->write('write some');
StreamWriter can be also created with
use Chevere\Components\Writer\StreamWriterFromString; $writer = new StreamWriterFromString(''); $writer->write('something else');