webarchitect609/stream-tools

Useful filters and other tools to be used with PHP Stream Functions.

0.0.2 2020-12-23 17:14 UTC

This package is auto-updated.

Last update: 2022-06-23 20:24:58 UTC


README

Be careful: it's the early alpha-version so far!

Build Status

Useful filters and other tools to be used with PHP Stream Functions.

How to use

  1. Install via composer

    composer require webarchitect609/stream-tools
  2. Register the desired filter.

    use WebArch\StreamTools\Filter\EndOfLineFilter;
    
    stream_filter_register(EndOfLineFilter::class, EndOfLineFilter::class);
  3. See the filter's phpDocs for help on usage and params. Attach the filter to the opened file resource or other stream.

    use WebArch\StreamTools\Enum\EndOfLine;
    use WebArch\StreamTools\Filter\EndOfLineFilter;
    /** @var resource $stream */
    stream_filter_append(
        $stream,
        EndOfLineFilter::class,
        STREAM_FILTER_WRITE,
        EndOfLine::WINDOWS
    );
  4. Enjoy!

    /** @var resource $stream */
    fputs($stream, "All LF symbols\nwill be replaced by CRLF symbols.\nThat's it!");