From 57610f7b34e89c65f7c9008fbb3d1a5ebc90a519 Mon Sep 17 00:00:00 2001 From: Kacper Pruszynski Date: Mon, 25 Mar 2024 22:06:52 +0100 Subject: [PATCH] [11.x] Register console commands, paths and routes after the app is booted (#50716) (#50738) Co-authored-by: Kacper Pruszynski --- .../Foundation/Configuration/ApplicationBuilder.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php b/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php index 0ee659a25055..37187367049b 100644 --- a/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php +++ b/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php @@ -257,9 +257,11 @@ public function withCommands(array $commands = []) [$commands, $paths] = collect($commands)->partition(fn ($command) => class_exists($command)); [$routes, $paths] = $paths->partition(fn ($path) => is_file($path)); - $kernel->addCommands($commands->all()); - $kernel->addCommandPaths($paths->all()); - $kernel->addCommandRoutePaths($routes->all()); + $this->app->booted(static function () use ($kernel, $commands, $paths, $routes) { + $kernel->addCommands($commands->all()); + $kernel->addCommandPaths($paths->all()); + $kernel->addCommandRoutePaths($routes->all()); + }); }); return $this;