LaravelPackages.net
Acme Inc.
Toggle sidebar
rahul900day/laravel-console-spinner

Laravel Console Spinner is a spinner output for Laravel command line.

128.596
76
1.2.0
About rahul900day/laravel-console-spinner

rahul900day/laravel-console-spinner is a Laravel package for laravel console spinner is a spinner output for laravel command line.. It currently has 76 GitHub stars and 128.596 downloads on Packagist (latest version 1.2.0). Install it with composer require rahul900day/laravel-console-spinner. Discover more Laravel packages by rahul900day or browse all Laravel packages to compare alternatives.

Last updated

Laravel Console Spinner

Laravel Console Spinner was created by Rahul Dey. It is just a custom Progress Bar inspired by icanhazstring/symfony-console-spinner.

StyleCI Status Total Downloads Version PHP Version Require

Installation

Requires PHP 7.3+

Via Composer:

composer require rahul900day/laravel-console-spinner

You can publish the config file with:

php artisan vendor:publish --tag=console-spinner-config

This is the contents of the published config file:

return [
    'chars' => ['⠏', '⠛', '⠹', '⢸', '⣰', '⣤', '⣆', '⡇'],
];

Usage

class SimpleLaravelCommand extends Command
{
    /**
     * Execute the console command.
     *
     * @return void
     */
    public function handle()
    {
        $spinner = $this->spinner($users->count());
        $spinner->setMessage('Loading...');
        $spinner->start();
        
        foreach ($users as $user) {
            // Do your stuff...
            
            $spinner->advance();
        }
        $spinner->finish();
    }
}

The $spinner is compatible with Symfony ProgressBar, so you can run any method of this class.

Or you can also use with withSpinner method by giving an iterable.

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

Licence

This package is released under the MIT license.

Star History Chart