8000 [9.x] Lazy load Laravel commands by paras-malhotra · Pull Request #34925 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

[9.x] Lazy load Laravel commands #34925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 22, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Lazy load migration commands
  • Loading branch information
paras-malhotra committed Oct 21, 2020
commit 78e855d86a1b34ace325e3caa01baae9250e85b2
36 changes: 16 additions & 20 deletions src/Illuminate/Database/MigrationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ class MigrationServiceProvider extends ServiceProvider implements DeferrableProv
* @var array
*/
protected $commands = [
'Migrate' => 'command.migrate',
'MigrateFresh' => 'command.migrate.fresh',
'MigrateInstall' => 'command.migrate.install',
'MigrateRefresh' => 'command.migrate.refresh',
'MigrateReset' => 'command.migrate.reset',
'MigrateRollback' => 'command.migrate.rollback',
'MigrateStatus' => 'command.migrate.status',
'MigrateMake' => 'command.migrate.make',
'Migrate' => MigrateCommand::class,
'MigrateFresh' => FreshCommand::class,
'MigrateInstall' => InstallCommand::class,
'MigrateRefresh' => RefreshCommand::class,
'MigrateReset' => ResetCommand::class,
'MigrateRollback' => RollbackCommand::class,
'MigrateStatus' => StatusCommand::class,
'MigrateMake' => MigrateMakeCommand::class,
];

/**
Expand Down Expand Up @@ -116,7 +116,7 @@ protected function registerCommands(array $commands)
*/
protected function registerMigrateCommand()
{
$this->app->singleton('command.migrate', function ($app) {
$this->app->singleton(MigrateCommand::class, function ($app) {
return new MigrateCommand($app['migrator'], $app[Dispatcher::class]);
});
}
Expand All @@ -128,9 +128,7 @@ protected function registerMigrateCommand()
*/
protected function registerMigrateFreshCommand()
{
$this->app->singleton('command.migrate.fresh', function () {
return new FreshCommand;
});
$this->app->singleton(FreshCommand::class);
}

/**
Expand All @@ -140,7 +138,7 @@ protected function registerMigrateFreshCommand()
*/
protected function registerMigrateInstallCommand()
{
$this->app->singleton('command.migrate.install', function ($app) {
$this->app->singleton(InstallCommand::class, function ($app) {
return new InstallCommand($app['migration.repository']);
});
}
Expand All @@ -152,7 +150,7 @@ protected function registerMigrateInstallCommand()
*/
protected function registerMigrateMakeCommand()
{
$this->app->singleton('command.migrate.make', function ($app) {
$this->app->singleton(MigrateMakeCommand::class, function ($app) {
// Once we have the migration creator registered, we will create the command
// and inject the creator. The creator is responsible for the actual file
// creation of the migrations, and may be extended by these developers.
Expand All @@ -171,9 +169,7 @@ protected function registerMigrateMakeCommand()
*/
protected function registerMigrateRefreshCommand()
{
$this->app->singleton('command.migrate.refresh', function () {
return new RefreshCommand;
});
$this->app->singleton(RefreshCommand::class);
}

/**
Expand All @@ -183,7 +179,7 @@ protected function registerMigrateRefreshCommand()
*/
protected function registerMigrateResetCommand()
{
$this->app->singleton('command.migrate.reset', function ($app) {
$this->app->singleton(ResetCommand::class, function ($app) {
return new ResetCommand($app['migrator']);
});
}
Expand All @@ -195,7 +191,7 @@ protected function registerMigrateResetCommand()
*/
protected function registerMigrateRollbackCommand()
{
$this->app->singleton('command.migrate.rollback', function ($app) {
$this->app->singleton(RollbackCommand::class, function ($app) {
return new RollbackCommand($app['migrator']);
});
}
Expand All @@ -207,7 +203,7 @@ protected function registerMigrateRollbackCommand()
*/
protected function registerMigrateStatusCommand()
{
$this->app->singleton('command.migrate.status', function ($app) {
$this->app->singleton(StatusCommand::class, function ($app) {
return new StatusCommand($app['migrator']);
});
}
Expand Down
0