PHP code example of legionth / reactphp-progressbar
1. Go to this page and download the library: Download legionth/reactphp-progressbar 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/ */
legionth / reactphp-progressbar example snippets
$loop = Factory::create();
$progressBarStream = new ProgressbarStream();
$input = new React\Stream\WritableResourceStream(STDOUT, $loop);
$output = new React\Stream\ReadableResourceStream(STDIN, $loop);
$output->pipe($progressBarStream);
$progressBarStream->on('error', function ($errorMessage) {
echo $errorMessage;
});
$progressBarStream->on('data', function ($progressBarString) use ($input) {
$input->write($progressBarString . PHP_EOL);
});
$loop->addPeriodicTimer(1, function () use ($output) {
$output->emit('data', array(1));
});
$loop->addPeriodicTimer(3, function () use ($output) {
$output->emit('data', array(10));
});
$loop->run();