PHP code example of lajosbencz / progress-bar

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

    

lajosbencz / progress-bar example snippets


use LajosBencz\ProgressBar;

$pb = ProgressBar\Factory::createDefault(10);

for($i=0; $i<10; $i++) {
    sleep(1);
    $pb($i + 1);
}

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

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