Laravel Console Spinner

Packages

September 2nd, 2021

laravel-custom-loader-featured.png

Laravel Console Spinner is a custom spinning progress bar for Laravel inspired by the Symfony Console Spinner:

console spinner demo

This package is specifically for Laravel artisan console commands and includes a few macros to make custom loading spinners. Using the spinner within an Artisan is simple and is compatible with the Symfony ProgressBar instance:

1public function handle()
2{
3 // $spinner is a ProgressBar instance
4 $spinner = $this->spinner($users->count());
5 $spinner->setMessage('Loading...');
6 $spinner->start();
7 
8 foreach ($users as $user) {
9 // Do your stuff...
10 
11 $spinner->advance();
12 }
13 $spinner->finish();
14}

Additionally, you can use the withSpinner() method which gives you an iterable:

1$this->withSpinner(User::all(), function($user) {
2 // Do your stuff with $user
3}, 'Loading...');

You can learn more about this package, get full installation instructions, and view the source code on GitHub.


This package was submitted to our Laravel News Links section. Links is a place the community can post packages and tutorials around the Laravel ecosystem. Follow along on Twitter @LaravelLinks

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.