From e216708d17f1b5f0b4de6ab81ff1f5c34c33488c Mon Sep 17 00:00:00 2001 From: Samuel Nitsche Date: Sun, 22 Sep 2024 17:16:55 +0200 Subject: [PATCH] Auto-Register Commands in `routes/console.php` (#52867) --- .../Foundation/Configuration/ApplicationBuilder.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php b/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php index 89ec3b9cc50f..21abba66917e 100644 --- a/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php +++ b/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php @@ -282,7 +282,11 @@ public function withMiddleware(?callable $callback = null) */ public function withCommands(array $commands = []) { - if (empty($commands)) { + if (empty($commands) && 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')]; }