diff --git a/src/Illuminate/Foundation/Console/ConfigMakeCommand.php b/src/Illuminate/Foundation/Console/ConfigMakeCommand.php new file mode 100644 index 000000000000..c4996d724c95 --- /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 configuration file even if it already exists'], + ]; + } + + /** + * Prompt for missing input arguments using the returned questions. + * + * @return array + */ + protected function promptForMissingArgumentsUsing() + { + return [ + 'name' => 'What should the configuration file be named?', + ]; + } +} diff --git a/src/Illuminate/Foundation/Console/stubs/config.stub b/src/Illuminate/Foundation/Console/stubs/config.stub new file mode 100644 index 000000000000..3ac44ad10138 --- /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, @@ -388,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. *