I know you can implement a progressbar for a console command in laravel like this:
$users = App\User::all();
$bar = $this->output->createProgressBar(count($users));
foreach ($users as $user) {
$this->performTask($user);
$bar->advance();
}
$bar->finish();
This works fine when you actually have your logic in the console command file itself. But how do you implement this when you have a helper file or controller that contains the foreach loop?
for example I am running a crawler with a selfwritten php artisan command:
public function handle(Crawler $crawler)
{
$this->info(PHP_EOL . "updating the database with beers data" . PHP_EOL);
$crawler->startCrawler('http://ift.tt/1TM2jkh', 'product-block', '/\d+\,?\d*CL/i');
}
My foreach loop is actually within my Crawler class here. How can I still get the progressbar to display properly?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire