Laravel Console Spinner is a custom spinning progress bar for Laravel inspired by the Symfony Console Spinner:
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 $user3}, 'Loading...');
You can learn more about this package, get full installation instructions, and view the source code on GitHub.
0 comments:
Post a Comment
Thanks