Skip to content

Instantly share code, notes, and snippets.

@golonix
Created January 30, 2018 09:38
Show Gist options
  • Save golonix/6bf2576d2b32249e10c50e4b3e8eff14 to your computer and use it in GitHub Desktop.
Save golonix/6bf2576d2b32249e10c50e4b3e8eff14 to your computer and use it in GitHub Desktop.
Artisan command with simple progress bar
<?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