diff --git a/src/Illuminate/Foundation/Console/Kernel.php b/src/Illuminate/Foundation/Console/Kernel.php index 334b3a401b43..77472eeaa74d 100644 --- a/src/Illuminate/Foundation/Console/Kernel.php +++ b/src/Illuminate/Foundation/Console/Kernel.php @@ -332,12 +332,15 @@ protected function load($paths) } $namespace = $this->app->getNamespace(); + $basePath = $this->app->basePath(); - foreach ((new Finder)->in($paths)->files() as $command) { - $command = $namespace.str_replace( - ['/', '.php'], - ['\\', ''], - Str::after($command->getRealPath(), realpath(app_path()).DIRECTORY_SEPARATOR) + foreach ((new Finder())->in($paths)->files() as $file) { + $class = trim(Str::replaceFirst($basePath, '', $file->getRealPath()), DIRECTORY_SEPARATOR); + + $command = str_replace( + [DIRECTORY_SEPARATOR, ucfirst(basename(app()->path())).'\\'], + ['\\', $namespace], + ucfirst(Str::replaceLast('.php', '', $class)), ); if (is_subclass_of($command, Command::class) &&