lajosbencz / progress-bar
Simple CLI progress bar for PHP
v0.1.2
2020-01-27 13:37 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: @stable
This package is auto-updated.
Last update: 2024-12-28 01:14:20 UTC
README
Extensible ANSI (only for terminals) progress bar for PHP
Install
composer require --save lajosbencz/progress-bar
Default usage
use LajosBencz\ProgressBar; $pb = ProgressBar\Factory::createDefault(10); for($i=0; $i<10; $i++) { sleep(1); $pb($i + 1); }
Customized usage
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); }
Factory usage
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); }
TODO
- Comments
- Interface with PSR logging facility
- Meaningful tests