Added symfony process to run initialization commands

This commit is contained in:
Alejandro Celaya 2016-08-14 23:40:54 +02:00
parent 1f3e31d100
commit 4bbdccf981
3 changed files with 19 additions and 1 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@ build
composer.lock
vendor/
.env
data/database.sqlite

View file

@ -27,6 +27,7 @@
"doctrine/orm": "^2.5",
"guzzlehttp/guzzle": "^6.2",
"symfony/console": "^3.0",
"symfony/process": "^3.0",
"firebase/php-jwt": "^4.0",
"monolog/monolog": "^1.21",
"theorchard/monolog-cascade": "^0.4",

View file

@ -4,6 +4,7 @@ namespace Shlinkio\Shlink\CLI\Command\Install;
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
use Shlinkio\Shlink\Core\Service\UrlShortener;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProcessHelper;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -34,6 +35,10 @@ class InstallCommand extends Command
* @var QuestionHelper
*/
private $questionHelper;
/**
* @var ProcessHelper
*/
private $processHelper;
/**
* @var WriterInterface
*/
@ -56,6 +61,7 @@ class InstallCommand extends Command
$this->input = $input;
$this->output = $output;
$this->questionHelper = $this->getHelper('question');
$this->processHelper = $this->getHelper('process');
$params = [];
$output->writeln([
@ -85,7 +91,17 @@ class InstallCommand extends Command
// Generate config params files
$config = $this->buildAppConfig($params);
$this->configWriter->toFile('config/params/generated_config.php', $config, false);
$output->writeln('<info>Custom configuration properly generated!</info>');
$output->writeln(['<info>Custom configuration properly generated!</info>', '']);
// Generate database
$output->write('Initializing database...');
$this->processHelper->run($output, 'php vendor/bin/doctrine.php orm:schema-tool:create');
$output->writeln(' <info>Success!</info>');
// Generate proxies
$output->write('Generating proxies...');
$this->processHelper->run($output, 'php vendor/bin/doctrine.php orm:generate-proxies');
$output->writeln(' <info>Success!</info>');
}
protected function askDatabase()