安装
composer require dariuszp/cli-progress-bar
引用
use Dariuszp\CliProgressBar;
使用
$bar = new CliProgressBar(count($data_count)); $bar->setBarLength(50); $bar->display(); $bar->setColorToYellow();
在循环中调用计数器
$bar->progress();
循环结束后
$bar->setColorToGreen(); $bar->display(); $bar->end();
效果
进行中(颜色都是可以自己设置的)
![php cli 进度条工具类 https://52ll.org/wp-content/uploads/2023/03/Snipaste_2023-03-01_00-35-03.png](https://52ll.org/wp-content/uploads/2023/03/Snipaste_2023-03-01_00-35-03.png)
已完成
![php cli 进度条工具类 https://52ll.org/wp-content/uploads/2023/03/Snipaste_2023-03-01_00-34-38.png](https://52ll.org/wp-content/uploads/2023/03/Snipaste_2023-03-01_00-34-38.png)
发表回复