From 0e32c9777f3238fac0c1328688417e7bcd49202f Mon Sep 17 00:00:00 2001 From: = Date: Thu, 28 Aug 2025 22:01:14 -0400 Subject: [PATCH 1/5] add make:config command --- .../Foundation/Console/ConfigMakeCommand.php | 86 +++++++++++++++++++ .../Foundation/Console/stubs/config.stub | 5 ++ .../Providers/ArtisanServiceProvider.php | 2 + 3 files changed, 93 insertions(+) create mode 100644 src/Illuminate/Foundation/Console/ConfigMakeCommand.php create mode 100644 src/Illuminate/Foundation/Console/stubs/config.stub diff --git a/src/Illuminate/Foundation/Console/ConfigMakeCommand.php b/src/Illuminate/Foundation/Console/ConfigMakeCommand.php new file mode 100644 index 000000000000..cffeda2ae27c --- /dev/null +++ b/src/Illuminate/Foundation/Console/ConfigMakeCommand.php @@ -0,0 +1,86 @@ + + */ + protected $aliases = ['config:make']; + + /** + * Get the destination file path. + * + * @param string $name + */ + protected function getPath($name): string + { + return config_path(Str::finish($this->argument('name'), '.php')); + } + + /** + * Get the stub file for the generator. + */ + protected function getStub(): string + { + $relativePath = join_paths('stubs', 'config.stub'); + + return file_exists($customPath = $this->laravel->basePath($relativePath)) + ? $customPath + : join_paths(__DIR__, $relativePath); + } + + /** + * Get the console command arguments. + */ + protected function getOptions(): array + { + return [ + ['force', 'f', InputOption::VALUE_NONE, 'Create the config even if it already exists'], + ]; + } + + /** + * Prompt for missing input arguments using the returned questions. + * + * @return array + */ + protected function promptForMissingArgumentsUsing() + { + return [ + 'name' => 'What should the config be named?', + ]; + } +} \ No newline at end of file diff --git a/src/Illuminate/Foundation/Console/stubs/config.stub b/src/Illuminate/Foundation/Console/stubs/config.stub new file mode 100644 index 000000000000..035fcd576717 --- /dev/null +++ b/src/Illuminate/Foundation/Console/stubs/config.stub @@ -0,0 +1,5 @@ + ChannelMakeCommand::class, 'ClassMake' => ClassMakeCommand::class, 'ComponentMake' => ComponentMakeCommand::class, + 'ConfigMake' => ConfigMakeCommand::class, 'ConfigPublish' => ConfigPublishCommand::class, 'ConsoleMake' => ConsoleMakeCommand::class, 'ControllerMake' => ControllerMakeCommand::class, From dfa8b633551165e4b54138a362d46375abc70779 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 29 Aug 2025 03:05:12 -0400 Subject: [PATCH 2/5] add registerConfigMakeCommand --- .../Foundation/Providers/ArtisanServiceProvider.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index 6e314ef1776c..3eccb5d7e85d 100755 --- a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -390,6 +390,18 @@ protected function registerConfigClearCommand() }); } + /** + * Register the command. + * + * @return void + */ + protected function registerConfigMakeCommand() + { + $this->app->singleton(ConfigMakeCommand::class, function ($app) { + return new ConfigMakeCommand($app['files']); + }); + } + /** * Register the command. * From 0dfc0d057efc3e51322437a490ace26dc61ff5c0 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 29 Aug 2025 08:33:23 -0500 Subject: [PATCH 3/5] Update config.stub --- src/Illuminate/Foundation/Console/stubs/config.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/stubs/config.stub b/src/Illuminate/Foundation/Console/stubs/config.stub index 035fcd576717..3ac44ad10138 100644 --- a/src/Illuminate/Foundation/Console/stubs/config.stub +++ b/src/Illuminate/Foundation/Console/stubs/config.stub @@ -2,4 +2,4 @@ return [ // -]; \ No newline at end of file +]; From 61459639554e3cd69601ae1018f035d3ea276273 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 29 Aug 2025 08:34:27 -0500 Subject: [PATCH 4/5] Update ConfigMakeCommand.php --- .../Foundation/Console/ConfigMakeCommand.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Foundation/Console/ConfigMakeCommand.php b/src/Illuminate/Foundation/Console/ConfigMakeCommand.php index cffeda2ae27c..e49adc65a3e8 100644 --- a/src/Illuminate/Foundation/Console/ConfigMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ConfigMakeCommand.php @@ -24,14 +24,14 @@ class ConfigMakeCommand extends GeneratorCommand * * @var string */ - protected $description = 'Create a new config'; + protected $description = 'Create a new configuration file'; /** * The type of file being generated. * * @var string */ - protected $type = 'Config'; + protected $type = 'Configuration'; /** * The console command name aliases. @@ -68,7 +68,7 @@ protected function getStub(): string protected function getOptions(): array { return [ - ['force', 'f', InputOption::VALUE_NONE, 'Create the config even if it already exists'], + ['force', 'f', InputOption::VALUE_NONE, 'Create the configuration file even if it already exists'], ]; } @@ -80,7 +80,7 @@ protected function getOptions(): array protected function promptForMissingArgumentsUsing() { return [ - 'name' => 'What should the config be named?', + 'name' => 'What should the configuration file be named?', ]; } -} \ No newline at end of file +} From d3b77e4bfa56188cec41ac429e06825829212611 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 29 Aug 2025 08:35:56 -0500 Subject: [PATCH 5/5] Update ConfigMakeCommand.php --- src/Illuminate/Foundation/Console/ConfigMakeCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/ConfigMakeCommand.php b/src/Illuminate/Foundation/Console/ConfigMakeCommand.php index e49adc65a3e8..c4996d724c95 100644 --- a/src/Illuminate/Foundation/Console/ConfigMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ConfigMakeCommand.php @@ -31,7 +31,7 @@ class ConfigMakeCommand extends GeneratorCommand * * @var string */ - protected $type = 'Configuration'; + protected $type = 'Config'; /** * The console command name aliases.