Jens Segers on

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.

Webmentions

Tweet about this blog post and you will appear below!