From 9b2e7383ead7d34da0dd80bc404df5e68535f5cc Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 21 Jul 2022 15:09:47 +0100 Subject: [PATCH 1/2] Improves console output of not found command --- src/Exceptions/Handler.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php index 5bf17a7a..91c82c52 100644 --- a/src/Exceptions/Handler.php +++ b/src/Exceptions/Handler.php @@ -4,6 +4,8 @@ use Exception; use Illuminate\Auth\Access\AuthorizationException; +use Illuminate\Console\View\Components\BulletList; +use Illuminate\Console\View\Components\Error; use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Contracts\Support\Responsable; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -14,6 +16,7 @@ use Illuminate\Validation\ValidationException; use Psr\Log\LoggerInterface; use Symfony\Component\Console\Application as ConsoleApplication; +use Symfony\Component\Console\Exception\CommandNotFoundException; use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; @@ -199,6 +202,23 @@ protected function renderExceptionWithSymfony(Throwable $e, $debug) */ public function renderForConsole($output, Throwable $e) { + if ($e instanceof CommandNotFoundException) { + $message = str($e->getMessage())->explode('.')->first(); + + if (! empty($alternatives = $e->getAlternatives())) { + $message .= '. Did you mean one of these?'; + + with(new Error($output))->render($message); + with(new BulletList($output))->render($e->getAlternatives()); + + $output->writeln(''); + } else { + with(new Error($output))->render($message); + } + + return; + } + (new ConsoleApplication)->renderThrowable($e, $output); } From e5314f9dbadd5a2d79e9a2fd115ed73f5b9589de Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 21 Jul 2022 15:09:53 +0100 Subject: [PATCH 2/2] Uses Laravel v9.21 --- composer.json | 50 ++++++++++++++++++++++----------------------- src/Application.php | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/composer.json b/composer.json index cd17ceb9..cd436282 100644 --- a/composer.json +++ b/composer.json @@ -16,31 +16,31 @@ ], "require": { "php": "^8.0.2", - "illuminate/auth": "^9.0", - "illuminate/broadcasting": "^9.0", - "illuminate/bus": "^9.0", - "illuminate/cache": "^9.0", - "illuminate/collections": "^9.0", - "illuminate/config": "^9.0", - "illuminate/console": "^9.0", - "illuminate/container": "^9.0", - "illuminate/contracts": "^9.0", - "illuminate/database": "^9.0", - "illuminate/encryption": "^9.0", - "illuminate/events": "^9.0", - "illuminate/filesystem": "^9.0", - "illuminate/hashing": "^9.0", - "illuminate/http": "^9.0", - "illuminate/macroable": "^9.0", - "illuminate/pagination": "^9.0", - "illuminate/pipeline": "^9.0", - "illuminate/queue": "^9.0", - "illuminate/support": "^9.0", - "illuminate/testing": "^9.0", - "illuminate/translation": "^9.0", - "illuminate/validation": "^9.0", - "illuminate/view": "^9.0", - "illuminate/log": "^9.0", + "illuminate/auth": "^9.21", + "illuminate/broadcasting": "^9.21", + "illuminate/bus": "^9.21", + "illuminate/cache": "^9.21", + "illuminate/collections": "^9.21", + "illuminate/config": "^9.21", + "illuminate/console": "^9.21", + "illuminate/container": "^9.21", + "illuminate/contracts": "^9.21", + "illuminate/database": "^9.21", + "illuminate/encryption": "^9.21", + "illuminate/events": "^9.21", + "illuminate/filesystem": "^9.21", + "illuminate/hashing": "^9.21", + "illuminate/http": "^9.21", + "illuminate/macroable": "^9.21", + "illuminate/pagination": "^9.21", + "illuminate/pipeline": "^9.21", + "illuminate/queue": "^9.21", + "illuminate/support": "^9.21", + "illuminate/testing": "^9.21", + "illuminate/translation": "^9.21", + "illuminate/validation": "^9.21", + "illuminate/view": "^9.21", + "illuminate/log": "^9.21", "dragonmantank/cron-expression": "^3.1", "nikic/fast-route": "^1.3", "symfony/console": "^6.0", diff --git a/src/Application.php b/src/Application.php index 1c917ba9..48604645 100644 --- a/src/Application.php +++ b/src/Application.php @@ -162,7 +162,7 @@ public function bootstrapRouter() */ public function version() { - return 'Lumen (9.0.3) (Laravel Components ^9.0)'; + return 'Lumen (9.0.3) (Laravel Components ^9.21)'; } /**