Skip to content
Closed
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
101 changes: 101 additions & 0 deletions src/Illuminate/Foundation/Console/ConfigMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php

namespace Illuminate\Foundation\Console;

use Illuminate\Console\Concerns\CreatesMatchingTest;
use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputOption;

#[AsCommand(name: 'make:config')]
class ConfigMakeCommand extends GeneratorCommand
{
use CreatesMatchingTest;

/**
* The console command name.
*
* @var string
*/
protected $name = 'make:config';

/**
* The name of the console command.
*
* This name is used to identify the command during lazy loading.
*
* @var string|null
*
* @deprecated
*/
protected static $defaultName = 'make:config';

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

/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
if (parent::handle() === false) {
return;
}

if ($this->option('clear-config')) {
$this->call('config:clear');
}
}

/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub()
{
return $this->resolveStubPath('/stubs/config.stub');
}

/**
* Resolve the fully-qualified path to the stub.
*
* @param string $stub
* @return string
*/
protected function resolveStubPath($stub)
{
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
? $customPath
: __DIR__.$stub;
}

/**
* Get the destination class path.
*
* @param string $name
* @return string
*/
protected function getPath($name)
{
return $this->laravel['path.config'].'/'.$this->argument('name').'.php';
}

/**
* Get the console command arguments.
*
* @return array
*/
protected function getOptions()
{
return [
['clear-config', 'c', InputOption::VALUE_NONE, 'Clear the config cache after creating the config file.'],
];
}
}
14 changes: 14 additions & 0 deletions src/Illuminate/Foundation/Console/stubs/config.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| {{ class }} Config File
|--------------------------------------------------------------------------
|
| This file is for storing the configurable of {{ class }}
|
*/

];
14 changes: 14 additions & 0 deletions src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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\ConsoleMakeCommand;
use Illuminate\Foundation\Console\DocsCommand;
use Illuminate\Foundation\Console\DownCommand;
Expand Down Expand Up @@ -153,6 +154,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid
'CastMake' => CastMakeCommand::class,
'ChannelMake' => ChannelMakeCommand::class,
'ComponentMake' => ComponentMakeCommand::class,
'ConfigMake' => ConfigMakeCommand::class,
'ConsoleMake' => ConsoleMakeCommand::class,
'ControllerMake' => ControllerMakeCommand::class,
'Docs' => DocsCommand::class,
Expand Down Expand Up @@ -340,6 +342,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