robs
313
3
Laravel

Target [Illuminate\Database\Migrations\MigrationRepositoryInterface] is not instantiable.

Posted 3 years ago by robs

Hi all,

I wanted to create a console command that just checks the status of the migrations and have some custom output. Therefore I inject the Migrator, same as the Laravel MigrateCommand is doing. But I get an error with that dependency injection:

 [Illuminate\Container\BindingResolutionException]
Target [Illuminate\Database\Migrations\MigrationRepositoryInterface] is not instantiable.

The command is nothing fancy so far:

<?php namespace My\Console\Commands;

use Illuminate\Database\Console\Migrations\BaseCommand;
use Illuminate\Database\Migrations\Migrator;
use Symfony\Component\Console\Input\InputOption;

class MigrateCheckCommand extends BaseCommand {

  protected $name = 'migrate:check';

  /**
   * Create a new command instance.
   *
   * @return void
   */
  public function __construct(Migrator $migrator) {
    parent::__construct();

    $this->migrator = $migrator;
  }

  ...
}

The exception is thrown before the constructor and when I remove the dependency injection, it's all fine. But want to use $this->migrator->repositoryExists() in my checks.

Any ideas?

Cheers, Rob

Please sign in or create an account to participate in this conversation.