khalyomede/console-reporter

Display a progress bar and logs in the same time to the console.

v0.1.4 2018-09-16 09:27 UTC

README

PHP from Packagist Packagist Packagist

Gif showing a command line that trigger the console report, with the progress bar and the logs that stack themselves above the progress bar as the progress bar advance until 100 percent

Summary

Installation

composer require --dev khalyomede/console-reporter:0.*

Example of use

Example 1: simple use case

require(__DIR__ . '/../vendor/autoload.php');

use Khalyomede\ConsoleReporter as Reporter;

$reporter = new Reporter;
$reporter->setMaxEntries(24);

foreach( range(1, 24) as $integer ) {
  $sleepTimeInMicroseconds = rand(5000, 500000);

  usleep($sleepTimeInMicroseconds);

  if( $integer % 8 === 0 ) {
    $reporter->info("test #$integer in progression...");
  }

  $reporter->report();
  $reporter->advance();
}
$ php example/example-1.php

  2018-09-16 08:45:29.595600 [INFO] test #8 in progression...

  2018-09-16 08:45:32.205500 [INFO] test #16 in progression...

  2018-09-16 08:45:34.570100 [INFO] test #24 in progression...

  24 / 24 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100 %

Supported shells

Operating system Shell Tested ? Working ? Need configuration ?
Windows bash
Windows MS-DOS
Windows PowerShell yes

Do no see your OS or shell ? This means it has not been tested.

You are more than welcomed if you want to test it in another configuration than one of the above. Just fill in an issue.

PowerShell configuration

Check that your font configuration is not set to Raster Fonts:

Photo of the powersheel configuration panel, on the font section

Check it to something else than Raster Fonts. The characters used in some progress bar should now apear correctly.

Credits

Powershell font photo taken from 4sysops