belazar13/cli-progress-bar

dev-master 2017-07-27 15:44 UTC

README

Simple php cli progress bar!

Install

composer require belazar13/cli-progress-bar

Quick start

use belazar13\CliProgressBar\ProgressBar;

require_once __DIR__ . '/autoload.php';

$pb = new ProgressBar(0, 1000);
for ($i = 0; $i < 1000; $i++)
{
    $pb->update();
    usleep(2000);
}

$pb->complete();

Put messages during progress

use belazar13\CliProgressBar\ProgressBar;

require_once __DIR__ . '/autoload.php';

$pb = new ProgressBar(0, 1000);
for ($i = 0; $i < 1000; $i++)
{
    $pb->update();
    if ($i % 100 == 0)
    {
        $pb->message('Some message ' . $i);
    }
    usleep(2000);
}

$pb->complete();
Output
1 / 1000 0.10%. ETA - 00:00:00
Some message 0
101 / 1000 10.10%. ETA - 00:00:18
Some message 100
201 / 1000 20.10%. ETA - 00:00:16
Some message 200
...