diff --git a/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php b/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php index 20ac6817bd0e..d4e28645ea8c 100644 --- a/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php @@ -4,6 +4,7 @@ use Illuminate\Console\Concerns\CreatesMatchingTest; use Illuminate\Console\GeneratorCommand; +use Illuminate\Support\Str; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; @@ -45,7 +46,9 @@ protected function replaceClass($stub, $name) { $stub = parent::replaceClass($stub, $name); - return str_replace(['dummy:command', '{{ command }}'], $this->option('command'), $stub); + $command = $this->option('command') ?: 'app:'.Str::of($name)->classBasename()->kebab()->value(); + + return str_replace(['dummy:command', '{{ command }}'], $command, $stub); } /** @@ -94,7 +97,7 @@ protected function getOptions() { return [ ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the console command already exists'], - ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned', 'command:name'], + ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that will be used to invoke the class'], ]; } }