1. Go to this page and download the library: Download elephox/stream library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
elephox / stream example snippets
use Elephox\Stream\StringStream;
use Elephox\Stream\AppendStream;
use Elephox\Stream\ResourceStream;
use Elephox\Stream\EmptyStream;
use Elephox\Stream\LazyStream;
$stream = new StringStream('Hello World!');
$stream->eof(); // false
$stream->read(5); // 'Hello'
$stream->readByte(); // 32 (space)
$stream->readLine(); // 'World!' (reads to eof or "\r\n")
$stream->eof(); // true
$stream->rewind(); // rewinds to the beginning
$stream->getContents(); // 'Hello World!'
$moreStreams = new AppendStream($stream, new StringStream(' And welcome to Elephox!'));
$moreStreams->rewind();
$moreStreams->readAllLines(eol: " "); // ['Hello', 'World!', 'And', 'welcome', 'to', 'Elephox!']
$moreStreams->rewind();
$moreStreams->read(15); // 'Hello World! An'
$moreStreams->seek(8, SEEK_END); // moves relative from end of streams
$moreStreams->read(8); // 'Elephox!'
// there are more stream types:
// wraps stream resources
$resourceStream = new ResourceStream(fopen('/etc/passwd', 'r'));
// not readable, not writeable, not seekable, always empty
$emptyStream = new EmptyStream();
// only executes the closure if needed
$lazyStream = new LazyStream(function() {
return new StringStream('Hello World!');
});
// and they are all combinable via the AppendStream:
$megaStream = new AppendStream(
$moreStreams,
new AppendStream(
$lazyStream,
$resourceStream,
),
);
$megaStream->getContents(); // 'Hello World! And welcome to Elephox!Hello World!' + </etc/passwd contents>
$megaStream->close(); // closes all streams and releases the resources
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.