PHP code example of khalyomede / console-reporter

1. Go to this page and download the library: Download khalyomede/console-reporter 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/ */

    

khalyomede / console-reporter example snippets




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();
}



use Khalyomede\ConsoleReporter as Reporter;
use Khalyomede\Style\ModernRounded;

$reporter = new Reporter;
$reporter->setMaxEntries(24);
$reporter->setStyle(ModernRounded::class);

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();
}



use Khalyomede\ConsoleStylable;
use Khalyomede\ConsoleReporter as Reporter;

class ModernStar implements ConsoleStylable {
  public static function progressingCharacter(): string {
    return '✧';
  }

  public static function progressedCharacter(): string {
    return '✦';
  }

  public static function startCharacter(): string {
    return '[';
  }

  public static function endCharacter(): string {
    return ']';
  }
}

const MAX = 24;

$numbers = range(1, MAX);

$reporter = new Reporter;

$reporter->setMaxEntries(MAX);
$reporter->setStyle(ModernStar::class);

foreach( $numbers as $number ) {
  $microseconds = rand(50000, 500000);

  usleep($microseconds);

  if( $number % 8 === 0 ) {
    $reporter->info("running iteration #$number");
  }

  $reporter->report();
  $reporter->advance();
}



use Khalyomede\ConsoleReporter as Reporter;

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

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();
}



use Khalyomede\ConsoleReporter as Reporter;

$reporter = new Reporter;
$reporter->setMaxEntries(10);
$reporter->setProgressBarSize(30);

$numbers = range(0, 9);

foreach( $numbers as $number ) {
  $sleepTimeInMicroSeconds = rand(50000, 500000);
  
  usleep($sleepTimeInMicroSeconds);

  $reporter->report();
  $reporter->advance();
}
bash
$ php example/example-4.php
  2018-10-04 21:42:31.842600  ⓘ  test #8 in progression...
  2018-10-04 21:42:33.992700  ⓘ  test #16 in progression...
  2018-10-04 21:42:35.393700  ⓘ  test #24 in progression...
  24 / 24 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100 %
bash
$ php example/example-5.php
  10 / 10 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100 %