Extensible ANSI (only for terminals) progress bar for PHP
composer require --save lajosbencz/progress-bar
use LajosBencz\ProgressBar;
$pb = ProgressBar\Factory::createDefault(10);
for($i=0; $i<10; $i++) {
sleep(1);
$pb($i + 1);
}
use LajosBencz\ProgressBar;
$pb = new ProgressBar\ProgressBar(10);
$pb->setFormatterClass(ProgressBar\Formatter\SimpleFormatter::class, [60]);
$pb->setOutput(STDOUT);
for($i=0; $i<10; $i++) {
sleep(1);
$pb($i + 1);
}
use LajosBencz\ProgressBar;
$pbf = new ProgressBar\Factory(
// formatter class name:
ProgressBar\Formatter\SimpleFormatter::class,
// formatter args, will be passed into the constructor:
[10, "|O-|"],
// output stream to write to:
STDERR
);
$pb = $pbf->create(10);
for($i=0; $i<10; $i++) {
sleep(1);
$pb($i + 1);
}
- Comments
- Interface with PSR logging facility
- Meaningful tests