webarchitect609/stream-tools

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

Installs: 1 146

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/webarchitect609/stream-tools

0.0.3 2024-07-04 12:21 UTC

This package is auto-updated.

Last update: 2025-10-04 15:00:06 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!");