Apologies if this is my misunderstanding rather than an error, but there's a weird issue when creating custom versions of certain migration commands, causing the container to throw a dependency error due to a failure to resolve $customStubPath for MigrationCreator:
Unresolvable dependency resolving [Parameter #1 [ <required> $customStubPath ]] in class Illuminate\Database\Migrations\MigrationCreator
I'm able to address the issue by adding the following to my AppServiceProvider, though I'm not sure if I'm missing a more appropriate way to handle this:
$this->app->when(MigrationCreator::class)
->needs('$customStubPath')
->give(function ($app) {
return $app->basePath('stubs');
});
Since MigrationCreator is being registered in the MigrationServiceProvider, I'm thinking the resolution failure is an error and that the above snippet should not be necessary, though I'm not sure what's actually behind the failed resolution.
app/Console/Commands/MigrateMakeCommand.php extending Illuminate\Database\Console\Migrations\MigrateMakeCommandYour solution is the correct one. Since we bind the migrator as a singleton to the container you'll explicitly have to tell how to resolve the path if you overwrite the command.
This code doesn't work for me. On the other hand, I made 2 different packages that extends that Class so I don't think that this would be the correct approach, one would overwrite the other or am I missing something?
Me too, that code doest not work for me... The error persist...
@gmutinel I found a solution.
In my case the error message was:
Unresolvable dependency resolving [Parameter #1 [
which IS NOT Illuminate\Database\MigrationsMigrationCreator
In my MigrationCreator, I just put $customStubPath=null on constructor since I overwrited the stubPath method and I don't need the attribute to have a "valid" value.
So checkout if you have a custom MigrationCreator class.
NOTE: I don't needed to do the solution which @thechrisroberts said. Maybe because I'm using Laravel 7.2
Hope this help to you.
Here is my MigrationCreator:

Damn, thanks, I was almost there!
The magic here is due to the fallback in the Illuminate\Container\Container.php file
protected function resolvePrimitive(ReflectionParameter $parameter)
{
if (! is_null($concrete = $this->getContextualConcrete('$'.$parameter->name))) {
return $concrete instanceof Closure ? $concrete($this) : $concrete;
}
if ($parameter->isDefaultValueAvailable()) {
return $parameter->getDefaultValue();
}
$this->unresolvablePrimitive($parameter);
}
That NULL works because of that isDefaulValueAvailable().
@driesvints what do you think about adding a default value like this to the Core function in order to fix this at the base (or add a tip to the Docs at least)?
@gmutinel feel free to send in a pr
is it ok for you @didix16 ? After all, the fix is yours
Yeah, no problem. If PR pasts the tests it is ok