1. Go to this page and download the library: Download react/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/ */
react / stream example snippets
$stream->on('data', function ($data) {
echo $data;
});
$stream->on('drain', function () use ($stream) {
echo 'Stream is now ready to accept more data';
});
$stream->on('pipe', function (ReadableStreamInterface $source) use ($stream) {
echo 'Now receiving piped data';
// explicitly close target if source emits an error
$source->on('error', function () use ($stream) {
$stream->close();
});
});
$source->pipe($stream);
$through = new ThroughStream(function ($data) {
if (!is_string($data)) {
throw new \UnexpectedValueException('Only strings allowed');
}
return $data;
});
$through->on('error', $this->expectCallableOnce()));
$through->on('close', $this->expectCallableOnce()));
$through->on('data', $this->expectCallableNever()));
$through->write(2);
$stdin = new ReadableResourceStream(STDIN);
$stdout = new WritableResourceStream(STDOUT);
$stdio = new CompositeStream($stdin, $stdout);
$stdio->on('data', function ($chunk) use ($stdio) {
$stdio->write('You said: ' . $chunk);
});
$source = new React\Stream\ReadableResourceStream(fopen('source.txt', 'r'));
$dest = new React\Stream\WritableResourceStream(fopen('destination.txt', 'w'));
$source->pipe($dest);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.