sunrise/stream

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

v1.0.21 2019-03-05 10:21 UTC

README

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

Awards

SymfonyInsight

Installation

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('http://php.net/', 'rb');

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

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

// closes the stream
$stream->close();

Test run

php vendor/bin/phpunit

Api documentation

https://phpdoc.fenric.ru/

Useful links