Created
January 30, 2018 09:38
-
-
Save golonix/6bf2576d2b32249e10c50e4b3e8eff14 to your computer and use it in GitHub Desktop.
Artisan command with simple progress bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Console\Command; | |
class SimpleAwesomeCommand extends Command | |
{ | |
/** | |
* @var string | |
*/ | |
protected $signature = 'awesome'; | |
/** | |
* @var string | |
*/ | |
protected $description = 'Run awesome command'; | |
/** | |
* @return void | |
*/ | |
public function handle() | |
{ | |
$this->comment('Doing something awesome ...'); | |
$bar = $this->output->createProgressBar(10); // or $bar = $this->output->createProgressBar(); | |
$bar->start(); // or $bar->start(10); | |
for ($i = 0; $i < 10; $i++) { | |
$bar->advance(); | |
usleep(700000); | |
} | |
$bar->finish(); | |
$bar->clear(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment