diff --git a/.gitignore b/.gitignore index 9695be68..aebab397 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ build composer.lock vendor/ .env +data/database.sqlite diff --git a/composer.json b/composer.json index b8dc3f63..88c74604 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/module/CLI/src/Command/Install/InstallCommand.php b/module/CLI/src/Command/Install/InstallCommand.php index 785a004f..bb19514f 100644 --- a/module/CLI/src/Command/Install/InstallCommand.php +++ b/module/CLI/src/Command/Install/InstallCommand.php @@ -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('Custom configuration properly generated!'); + $output->writeln(['Custom configuration properly generated!', '']); + + // Generate database + $output->write('Initializing database...'); + $this->processHelper->run($output, 'php vendor/bin/doctrine.php orm:schema-tool:create'); + $output->writeln(' Success!'); + + // Generate proxies + $output->write('Generating proxies...'); + $this->processHelper->run($output, 'php vendor/bin/doctrine.php orm:generate-proxies'); + $output->writeln(' Success!'); } protected function askDatabase()