title: Using a Progress Bar while Seeding a database in Laravel
body: <p>I have to seed quite a lot of data into a database and I want to be able to show the user a progress bar while this happens. I know this is documented:</p>
  
  <ul>
  <li><a href="https://laravel.com/docs/master/artisan#registering-commands" rel="noreferrer">https://laravel.com/docs/master/artisan#registering-commands</a> (just above)</li>
  <li><a href="http://symfony.com/doc/2.7/components/console/helpers/progressbar.html" rel="noreferrer">http://symfony.com/doc/2.7/components/console/helpers/progressbar.html</a></li>
  </ul>
  
  <p>but I'm having problems including it in my seeder.</p>
  
  <pre><code>&lt;?php
  
  use Illuminate\Database\Seeder;
  
  class SubDivisionRangeSeeder extends Seeder
  {
      public function run()
      {
          $this-&gt;output-&gt;createProgressBar(10);
          for ($i = 0; $i &lt; 10; $i++) {
              sleep(1);
              $this-&gt;output-&gt;advance();
          }
          $this-&gt;output-&gt;finish();
      }
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;?php
  
  use Illuminate\Database\Seeder;
  
  class SubDivisionRangeSeeder extends Seeder
  {
      public function run()
      {
          $this-&gt;output-&gt;progressStart(10);
          for ($i = 0; $i &lt; 10; $i++) {
              sleep(1);
              $this-&gt;output-&gt;progressAdvance();
          }
          $this-&gt;output-&gt;progressFinish();
      }
  }
  </code></pre>
  
  <p>from <a href="https://mattstauffer.co/blog/advanced-input-output-with-artisan-commands-tables-and-progress-bars-in-laravel-5.1" rel="noreferrer">https://mattstauffer.co/blog/advanced-input-output-with-artisan-commands-tables-and-progress-bars-in-laravel-5.1</a></p>
  
  <p>Any ideas?</p>