Skip to content

Container failing to resolve $customStubPath on MigrationCreator #31978

@thechrisroberts

Description

@thechrisroberts
  • Laravel Version: 7.1.13
  • PHP Version: 7.4.1
  • Database Driver & Version: MySQL 8.0.18

Description:

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.

Steps To Reproduce:

  • Create a custom (even if just empty) app/Console/Commands/MigrateMakeCommand.php extending Illuminate\Database\Console\Migrations\MigrateMakeCommand
  • Run any Artisan command; this should be enough to trigger the error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions