crysalead/storage-stream

Object-Oriented API for PHP streams

1.0.6 2019-11-11 19:16 UTC

This package is auto-updated.

Last update: 2024-12-18 00:41:11 UTC


README

Build Status Code Coverage

Object-Oriented API for PHP streams (PSR-7 compatible).

Installation

composer require crysalead/storage-stream

Example

use Lead\Storage\Stream;

$stream = new Stream(fopen('smiley.png', 'r'));
$image = '';
while (!$stream->eof()) {
  $image .= $stream->read();
}

echo $stream->mime(); // 'image/png'

Pipe Example

use Lead\Storage\Stream;

$stream1 = new Stream("Hello");
$stream2 = new Stream("xxxxxWorld");

// copy the contents from the first stream to the second one
$stream1->pipe($stream2);

echo (string) $stream2; // 'HelloWorld'

Acknowledgements

Original implementation: Francois Zaninotto.