PHP code example of guiguiboy / php-cli-progress-bar

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

    

guiguiboy / php-cli-progress-bar example snippets



_once 'ProgressBar/Registry.php';

$progressBar = new \ProgressBar\Manager(0, 10);

for ($i = 0; $i <= 10; $i++)
{
    $progressBar->update($i);
    sleep(1);
}

foreach ($array as $element)
{
    // process element
    $progressBar->advance();
}

$progressBar->setFormat('%current% |%bar%| %max%');
$progressBar->update(1);

$pb = new \ProgressBar\Manager(0, 20, 120);
$progressBar->update(1);

$pb = new \ProgressBar\Manager(0, 20, 120, '-', ' ', ')');
$pb->update(5);



use ProgresBar;

$pb = new Manager(0, 213);
$pb->setFormat('Progress : %current%/%max% [%bar%] %foo%');
$pb->addReplacementRule('%foo%', 70, function ($buffer, $registry) {return 'OK!';});
$pb->update(1);