Jens Segers on Jun 13 2015

CLI progress bars in Laravel

Laravel 5.1 was released this week, and it came with a lot of interesting goodies. One of those goodies was the addition of Symfony's progress bar support for console commands. I have a lot of commands that I use to perform periodic tasks, and this will certainly make the output a lot nicer!

$this->output->progressStart(count($users));

foreach ($users as $user) {
    $this->performTask($user);

    $this->output->progressAdvance();
}

$this->output->progressFinish();

Which generates this output:

> php artisan my:command
17/50 [=========>------------------]  34%

For more information about this feature, check the original Laravel documentation.


Comments

datashaman 6 months ago

Rafael, this was posted recently to github. I have not tried it, but it purports to be what you want.

https://packagist.org/packages/loduis/artisan


Rafael Santos 1 year ago

I know this isn't related, but you seem to know a lot about Laravel. Is there a way to use Artisan or something similar in a framework agnostic way?


wouterds 1 year ago

Nice, going to try this!