PHP code example of macroman / terminal-progress-bar

1. Go to this page and download the library: Download macroman/terminal-progress-bar 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/ */

    

macroman / terminal-progress-bar example snippets


// examples/basic.php
use TerminalProgress\Bar;

$pg = new Bar(1000);

for ($i = 0; $i < 1000; $i++) {
	usleep(10000);
	$pg->tick();
}

// examples/update.php
use TerminalProgress\Bar;

$pg = new Bar(1000);

for ($i = 0; $i < 1000; $i++) {
	usleep(10000);
	$pg->update($i);
}

// examples/format.php
// Full options
new Bar(10, "Progress: [:bar] - :current/:total - :percent% - Elapsed::elapseds - ETA::etas - Rate::rate/s");

// examples/format_percent.php
// Just percentage plus the bar
new Bar(10, ":bar :percent%");

// examples/format_no_bar.php
// You don't even have to have a bar
new Bar(10, "Look mum, no bar! :current/:total - :percent% - Elapsed::elapseds - ETA::etas - Rate::rate/s");

// examples/interrupt.php
$pg = new Bar(1000);

for ($i = 0; $i < 1000; $i++) {
	usleep(10000);
	if ($i % 100 == 0) {
		// Interupt every 100th tick
		$pg->interupt($i);
	}
	$pg->tick();
}

// examples/symbols.php
$pg = new Bar(1000);

$pg->symbolComplete = "#";
$pg->symbolIncomplete = "-";

$pg->secondPrecision = 2;
$pg->percentPrecision = 4;

// examples/throttle.php
$pg = new Bar(1000);
$pg->throttle = 0.05; // Set a 50 millisecond throttle