Skip to content

Commit ba65cc5

Browse files
List possible values for database driver (#426)
* List possible values for database driver Nobody has to guess anymore what the possible values are for the --database option. * Update NewCommand.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent ec7f201 commit ba65cc5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/NewCommand.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class NewCommand extends Command
2626
use Concerns\ConfiguresPrompts;
2727
use Concerns\InteractsWithHerdOrValet;
2828

29+
const DATABASE_DRIVERS = ['mysql', 'mariadb', 'pgsql', 'sqlite', 'sqlsrv'];
30+
2931
/**
3032
* The Composer instance.
3133
*
@@ -49,7 +51,7 @@ protected function configure()
4951
->addOption('branch', null, InputOption::VALUE_REQUIRED, 'The branch that should be created for a new repository', $this->defaultBranch())
5052
->addOption('github', null, InputOption::VALUE_OPTIONAL, 'Create a new repository on GitHub', false)
5153
->addOption('organization', null, InputOption::VALUE_REQUIRED, 'The GitHub organization to create the new repository for')
52-
->addOption('database', null, InputOption::VALUE_REQUIRED, 'The database driver your application will use')
54+
->addOption('database', null, InputOption::VALUE_REQUIRED, 'The database driver your application will use. Possible values are: '.implode(', ', self::DATABASE_DRIVERS))
5355
->addOption('react', null, InputOption::VALUE_NONE, 'Install the React Starter Kit')
5456
->addOption('vue', null, InputOption::VALUE_NONE, 'Install the Vue Starter Kit')
5557
->addOption('livewire', null, InputOption::VALUE_NONE, 'Install the Livewire Starter Kit')
@@ -561,8 +563,8 @@ protected function databaseOptions(): array
561563
*/
562564
protected function validateDatabaseOption(InputInterface $input)
563565
{
564-
if ($input->getOption('database') && ! in_array($input->getOption('database'), $drivers = ['mysql', 'mariadb', 'pgsql', 'sqlite', 'sqlsrv'])) {
565-
throw new \InvalidArgumentException("Invalid database driver [{$input->getOption('database')}]. Valid options are: ".implode(', ', $drivers).'.');
566+
if ($input->getOption('database') && ! in_array($input->getOption('database'), self::DATABASE_DRIVERS)) {
567+
throw new \InvalidArgumentException("Invalid database driver [{$input->getOption('database')}]. Possible values are: ".implode(', ', self::DATABASE_DRIVERS).'.');
566568
}
567569
}
568570

0 commit comments

Comments
 (0)