PHP code example of pointybeard / helpers-cli-progressbar
1. Go to this page and download the library: Download pointybeard/helpers-cli-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/ */
pointybeard / helpers-cli-progressbar example snippets
declare(strict_types=1);
gressBar;
use pointybeard\Helpers\Cli\Colour;
$progress = (new ProgressBar\ProgressBar(rand(10000, 20000)))
->length(30)
->foreground(Colour\Colour::FG_GREEN)
->background(Colour\Colour::BG_DEFAULT)
->format('{{PROGRESS_BAR}} {{PERCENTAGE}}% {{COMPLETED}}/{{TOTAL}} ({{REMAINING_TIME}} remaining)')
;
// Optional. Seeds the start time of the progress bar. time() is used
// if omitted.
$progress->start();
do {
// This moves the progress forward (default is 1 unit) and redraws it
$progress->advance();
// Slow the script down so we can see what's happening
usleep(rand(5000, 20000));
} while ($progress->remaining() > 0);
echo PHP_EOL.'Work complete!'.PHP_EOL;