aeno / php-slickprogress
Lightweight but beautiful CLI progress bars and spinners
1.0.1
2021-06-17 11:20 UTC
Requires
- php: ^7.1||^7.2||^7.3||^7.4||^8.0
Requires (Dev)
- vimeo/psalm: ^4.4
README
Lightweight but beautiful PHP progress bars and spinners.
No dependencies
- works with PHP 7.1+
Installation
composer require aeno/php-slickprogress
Usage
Simple progress
$progress = new \Aeno\SlickProgress\Progress(); $progress->start(50); for ($i = 0; $i < 50; $i++) { $progress->advance(); usleep(25000); } $progress->finish();
Detailed progress
$theme = new \Aeno\SlickProgress\Theme\Simple(); $theme->showStep(true); $theme->showPercent(true); $progress = new \Aeno\SlickProgress\Progress($theme); $progress->start(200); for ($i = 0; $i < 200; $i++) { $progress->advance(); usleep(25000); } $progress->finish();
Indefinite progress
$progress = new \Aeno\SlickProgress\Progress(); $progress->start(-1); for ($i = 0; $i < 200; $i++) { $progress->advance(); usleep(25000); } $progress->finish();
Spinner
$foobar = new \Foobar(); // your business logic $theme = new \Aeno\SlickProgress\Theme\Snake(); $theme->setColorType(\Aeno\SlickProgress\Colors::COLOR_TYPE_ANSI256); $progress = new \Aeno\SlickProgress\Progress($theme); $progress->start(-1); for ($i = 0; $i < 100; $i++) { if ($foobar->hasNewStatus()) { $progress->setStatusMessage($foobar->getCurrentStatus()); } $progress->advance(); usleep(50000); } $progress->finish(\Aeno\SlickProgress\ThemeInterface::FINISH_TYPE_MESSAGE, '✅ Done!');
License
php-slickprogress is licensed under the Mozilla Public License, v. 2.0.