Simple Stream wrapper for PHP 7.1+ based on PSR-7 & PSR-17

v1.3.1 2021-11-30 10:05 UTC


Gitter Build Status Code Coverage Scrutinizer Code Quality Total Downloads Latest Stable Version License




composer require sunrise/stream

How to use?

use Sunrise\Stream\Stream;
use Sunrise\Stream\StreamFactory;

// creates a new stream without a factory
$stream = new Stream(fopen(...));

// creates a new stream from the given string
$stream = (new StreamFactory)->createStream('Hello, world!');

// creates a new stream from the given filename or URI
$stream = (new StreamFactory)->createStreamFromFile('', 'rb');

// creates a new stream from the given resource
$stream = (new StreamFactory)->createStreamFromResource(fopen(...));

// creates a new stream from temporary file (available from version 1.3)
$stream = (new StreamFactory)->createStreamFromTemporaryFile(?string);

// converts the stream to string
(string) $stream;

// closes the stream

Test run

php vendor/bin/phpunit

Useful links