From 815e9ff59ff4919c2869a1c6341c2ffc7b4ef188 Mon Sep 17 00:00:00 2001 From: Samuel Nitsche Date: Tue, 24 Sep 2024 17:24:07 +0200 Subject: [PATCH] Fix for not automatically registering commands in App\Console\Commands --- .../Foundation/Configuration/ApplicationBuilder.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php b/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php index 21abba66917e..a0f9754d9697 100644 --- a/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php +++ b/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php @@ -282,12 +282,14 @@ public function withMiddleware(?callable $callback = null) */ public function withCommands(array $commands = []) { - if (empty($commands) && is_file($this->app->basePath('routes/console.php'))) { - $commands = [$this->app->basePath('routes/console.php')]; - } + if (empty($commands)) { + if (is_file($this->app->basePath('routes/console.php'))) { + $commands = [$this->app->basePath('routes/console.php')]; + } - if (empty($commands) && is_dir($this->app->path('Console/Commands'))) { - $commands = [$this->app->path('Console/Commands')]; + if (is_dir($this->app->path('Console/Commands'))) { + $commands = [...$commands, $this->app->path('Console/Commands')]; + } } $this->app->afterResolving(ConsoleKernel::class, function ($kernel) use ($commands) {