Skip to content

Instantly share code, notes, and snippets.

@djaiss
Last active May 4, 2024 15:03
Show Gist options
  • Save djaiss/6685a6033b62e7eb3430b80a3bf258cc to your computer and use it in GitHub Desktop.
Save djaiss/6685a6033b62e7eb3430b80a3bf258cc to your computer and use it in GitHub Desktop.
Laravel: Use progress bars in migrations
<?php
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\ConsoleOutput;
class DoSomething extends Migration
{
public function up()
{
$output = new ConsoleOutput();
$progress = new ProgressBar($output, count($contacts));
$progress->start();
foreach ($contacts as $contact) {
// DO SOMETHING
$progress->advance();
}
$progress->finish();
}
}
@jonhassall
Copy link

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment