Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions src/Illuminate/Foundation/Console/ConfigMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace Illuminate\Foundation\Console;

use Illuminate\Console\GeneratorCommand;
use Illuminate\Support\Str;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputOption;

use function Illuminate\Filesystem\join_paths;

#[AsCommand(name: 'make:config', aliases: ['config:make'])]
class ConfigMakeCommand extends GeneratorCommand
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $name = 'make:config';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new configuration file';

/**
* The type of file being generated.
*
* @var string
*/
protected $type = 'Config';

/**
* The console command name aliases.
*
* @var array<int, string>
*/
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?',
];
}
}
5 changes: 5 additions & 0 deletions src/Illuminate/Foundation/Console/stubs/config.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
//
];
14 changes: 14 additions & 0 deletions src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use Illuminate\Foundation\Console\ComponentMakeCommand;
use Illuminate\Foundation\Console\ConfigCacheCommand;
use Illuminate\Foundation\Console\ConfigClearCommand;
use Illuminate\Foundation\Console\ConfigMakeCommand;
use Illuminate\Foundation\Console\ConfigPublishCommand;
use Illuminate\Foundation\Console\ConfigShowCommand;
use Illuminate\Foundation\Console\ConsoleMakeCommand;
Expand Down Expand Up @@ -189,6 +190,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid
'ChannelMake' => ChannelMakeCommand::class,
'ClassMake' => ClassMakeCommand::class,
'ComponentMake' => ComponentMakeCommand::class,
'ConfigMake' => ConfigMakeCommand::class,
'ConfigPublish' => ConfigPublishCommand::class,
'ConsoleMake' => ConsoleMakeCommand::class,
'ControllerMake' => ControllerMakeCommand::class,
Expand Down Expand Up @@ -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.
*
Expand Down
Loading