title: Dependency Injection from Package Command
body: <p>I am creating a command for my package.</p>
  
  <p>My constructor is:</p>
  
  <pre><code>public function __construct(\Artisan $artisan)
  {
      parent::__construct();
  
      $this-&gt;artisan = $artisan;
  }
  </code></pre>
  
  <p>Protected <code>$artisan</code> property, of course, is present.</p>
  
  <p>In my service provider <code>register()</code> method I have tried several methods for registering the command.</p>
  
  <p>First:</p>
  
  <pre><code>$this-&gt;app['custom.command'] = $this-&gt;app-&gt;share(function ($app)
  {
      return new CustomCommand(new \Artisan);
  });
  $this-&gt;commands('custom.command');
  </code></pre>
  
  <p>Second:</p>
  
  <pre><code>$this-&gt;app['custom.command'] = $this-&gt;app-&gt;share(function ($app)
  {
      return $app-&gt;make('CustomCommand');
  });
  $this-&gt;commands('custom.command');
  </code></pre>
  
  <p>Normally, it is supposed to work. But when I run the command I always get <code>Call to undefined method Illuminate\Support\Facades\Artisan::call()</code> error message as soon as I run <code>$this-&gt;artisan-&gt;call('migrate')</code> in my <code>fire()</code> method.</p>
  
  <p>However when I write <code>\Artisan::call('migrate')</code> instead of the <code>$this-&gt;artisan-&gt;call('migrate')</code> everything works fine.</p>
  
  <p>Does someone have an idea what I did wrong?</p>
  
  <p>Thanks in advance.</p>