crysalead / storage-stream
Object-Oriented API for PHP streams
Installs: 17 506
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=7
- ext-fileinfo: *
- psr/http-message: ~1.0
Requires (Dev)
- crysalead/dir: ~2.0
- kahlan/kahlan: ~3.0
README
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.