https://github.com/mrdatawolf/multilineprogressbar
Multiline progressbar creator for Laravel 5
https://github.com/mrdatawolf/multilineprogressbar
Last synced: 26 days ago
JSON representation
Multiline progressbar creator for Laravel 5
- Host: GitHub
- URL: https://github.com/mrdatawolf/multilineprogressbar
- Owner: mrdatawolf
- License: mit
- Created: 2018-08-24T19:02:32.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-27T22:43:15.000Z (almost 7 years ago)
- Last Synced: 2025-02-16T21:43:17.167Z (4 months ago)
- Language: PHP
- Homepage:
- Size: 1.1 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Multiline Progressbar creator
*Display multiple progressbars and update them at the same time.*
---### Use case:
*Display one or more progressbars in the console at the same time*## Composer Install
Add the following to your `composer.json`
```
{
"require": {
"mrdatawolf/multiline-progressbar": "dev-master"
}
}
```### 5.1 Notes
**This has only been tested on Laravel 5.1 but probably works with other versions**It allows up to 3 rows of progressbars and a messagebar to be run as a group.
**Example**
```
$totalBars = 3;
$xMax = 3;
$yMax = ($totalBars > 1) ? 4 : 0;
$zMax = ($totalBars > 2) ? 10 : 0;
$totalYs=0;
$totalZs=0;
$this->progressBar = new MultilineProgressbar($this->output, 'Processing Events', '|', $xMax, $yMax, $zMax);
if($this->option('debug')) {
$this->progressBar->debug();
}
$this->progressBar->start();
$this->progressBar->setMessage('Working thru ' . $xMax . ' primary blocks and '. $yMax . ' secondary blocks with ' . $zMax . ' atomic items','message');
for($x=1; $x<=$xMax;$x++) {
$this->progressBar->setMessage('Working in main block '. ($x), 'progress');
$this->progressBar->advance(['message','progress']);
if($totalBars > 1) {
for ($y = 1; $y <= $yMax; $y++) {
$totalYs++;
$this->progressBar->setMessage('Working in secondary group '.$totalYs,'progress2');
$this->progressBar->advance(['progress2']);
if($totalBars > 2) {
for ($z = 1; $z <= $zMax; $z++) {
$mainMessageAddendum = ($z % 7 == 0) ? 'foo' : 'bar';
$this->progressBar->setMessage('Working thru ' . $xMax . ' primary blocks and '. $yMax . ' secondary blocks with ' . $zMax . ' atomic items - '. $mainMessageAddendum);
$totalZs++;
usleep(100000);
$this->progressBar->setMessageAndSpinAndAdvance('Working with atomic unit '.$totalZs, 'progress3');
}
}
usleep(100000);
}
}
usleep(100000);
}
$this->progressBar->finish();
```The above will create 3 progressbars and a "message" bar above the progressbars. It will also put a "spinner" to the right of the message in the message bar.
**Sample Output**
```
Working thru 3 primary blocks and 4 secondary blocks with 10 atomic items -> | : 14 secs/14 secs 24.0 MiB
Working in main block 3 : 3/3 [============================] 100%
Working in secondary group 12 : 12/12 [============================] 100%
Working with atomic unit 120 : 120/120 [============================] 100%```
**Special Thanks**This project was made possible by [Let's Go Learn](http://letsgolearn.com/)