Skip to content

Commit

Permalink
[feature] allow MySQL host/port to be configured
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Aug 7, 2020
1 parent f9328d0 commit b063b47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion resources/config.inc.template
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ $i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['host'] = '%%mysql_host%%';
$cfg['Servers'][$i]['port'] = '%%mysql_port%%';
$cfg['Servers'][$i]['user'] = '%%mysql_user%%';
$cfg['Servers'][$i]['password'] = '%%mysql_password%%';
$cfg['Servers'][$i]['compress'] = false;
Expand Down
4 changes: 4 additions & 0 deletions src/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new SymfonyStyle($input, $output);

$address = $io->ask('Address?', '127.0.0.1:8888');
$mysqlHost = $io->ask('MySQL Host?', 'localhost');
$mysqlPort = $io->ask('MySQL Port?', '3306');
$mysqlUser = $io->ask('MySQL User?', 'root');
$mysqlPass = $io->askHidden('MySQL Password?', function ($value) {
return (string) $value;
Expand All @@ -43,6 +45,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io->comment('Generating config.inc.php');
$config = file_get_contents(__DIR__.'/../resources/config.inc.template');
file_put_contents($this->getDocumentRoot().'/config.inc.php', strtr($config, [
'%%mysql_host%%' => $mysqlHost,
'%%mysql_port%%' => $mysqlPort,
'%%mysql_user%%' => $mysqlUser,
'%%mysql_password%%' => $mysqlPass,
]));
Expand Down

0 comments on commit b063b47

Please sign in to comment.