Skip to content

Commit

Permalink
[minor] init improvements:
Browse files Browse the repository at this point in the history
- show composer output if verbose (-v) (closes #2)
- throw exception if process fails
  • Loading branch information
kbond committed Jul 27, 2021
1 parent b2c866b commit 5b00c3c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,28 @@ protected function execute(InputInterface $input, OutputInterface $output)

(new Filesystem())->remove($this->getDocumentRoot());

$io->comment('Downloading latest version of phpMyAdmin...');

$package = 'phpmyadmin/phpmyadmin';

if ($version) {
$package .= ':'.$version;
}

(new Process(['composer', 'create-project', $package, '.phpmyadmin'], $this->getHomeDir()))
$io->comment(\sprintf('Downloading phpMyAdmin <info>%s</info>...', $version ?: 'latest'));

$process = (new Process(['composer', 'create-project', $package, '.phpmyadmin'], $this->getHomeDir()))
->setTimeout(null)
->run()
;

$process->run(function($type, $buffer) use ($io) {
if ($io->isVerbose()) {
$io->writeln($buffer);
}
});

if (!$process->isSuccessful()) {
throw new \RuntimeException($process->getErrorOutput());
}

$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, [
Expand Down

0 comments on commit 5b00c3c

Please sign in to comment.