PHP CLI Progress Bar: Show a progress bar in a console terminal

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-12-01 (9 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 66 All time: 9,895 This week: 236Up
Version License PHP version Categories
php_component_cli_pr 1.0GNU Lesser Genera...5PHP 5, Utilities and Tools, Console
Description Author

This class can show a progress bar in a console terminal.

It can display a progress bar in a way that it shows the number of steps that were performed for a task divided in given number of smaller tasks.

The class can advance to the next step until all the steps are done and it updates the ways the progress bar appears to reflect the proportion of steps that were done compared to the total number steps.

Picture of nvb
  Performance   Level  
Name: nvb <contact>
Classes: 17 packages by
Country: Germany Germany
Age: ???
All time rank: 1605104 in Germany Germany
Week rank: 201 Up13 in Germany Germany Up
Innovation award
Innovation award
Nominee: 10x

Details

Progress Bar for PHP CLI Scripts / Shell Environment

This project aims to deliver a easy to use php component for displaying a progress bar in the shell environment.

The current change log can be found here.

Usage

//assuming $items contains an array of items
$progressBar = new \Net\Bazzline\Component\Cli\ProgressBar\ProgressBar();

$progressBar->setTotalSteps(count($items));

foreach ($items as $item) {
    //do something with the item
    $progressBar->forward();
}
//to be on the save side, tell the progress bar that the show is over ;-)
$progressBar->isFinished();

Example

cd <project root>
./example/run.php

+-----------------------------+
| Example of the progress bar |
+-----------------------------+
This demo will demonstrate 5 progress bars.
The number of items will be 3, 6, 9, 12, 150.
The current update interval is 1 second.

Press CTRL-C to stop this demonstration

========================================================================>

Links (other good projects)

  • https://github.com/levi-putna/phpcli
  • https://github.com/guiguiboy/PHP-CLI-Progress-Bar
  • https://nixshell.wordpress.com/2009/09/08/get-the-width-of-the-terminal/

Final Words

Star it if you like it :-). Add issues if you need it. Pull patches if you enjoy it. Write a blog entry if you use it :-D.

  Files folder image Files  
File Role Description
Files folder imageexample (1 file)
Files folder imagesource (1 file)
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file run.php Example Example script

  Files folder image Files  /  source  
File Role Description
  Plain text file ProgressBar.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:66
This week:0
All time:9,895
This week:236Up
For more information send a message to info at phpclasses dot org.