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

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

    

nickbeen / php-cli-progress-bar example snippets


$progressBar = new \NickBeen\ProgressBar\ProgressBar(maxProgress: 62);
$progressBar->start();

doSomething();
$progressBar->tick();

doSomethingElse();
$progressBar->tick();

doSixtyTasks();
$progressBar->tick(60);

$progressBar->finish();

$array = [
    1 => 'A',
    2 => 'B',
    3 => 'C',
];

$progressBar = new \NickBeen\ProgressBar\ProgressBar();

foreach ($progressBar->iterate($array as $key => $value);) {
    echo "$key: $value" . PHP_EOL;
}

foreach ($progressBar->iterate($array);) {
    // Some custom notification
    sendToDiscord($progressBar->getEstimatedTime());

    // Some custom task application
    syncWithCloud($progressBar->getPercentage())

    // Some other custom application
    sendToRaspberryPiDisplay($progressBar->getProgress(), $progressBar->getMaxProgress())
}