* @package PHPCI * @subpackage Console */ class UpdateCommand extends Command { /** * @var \Monolog\Logger */ protected $logger; public function __construct(Logger $logger, $name = null) { parent::__construct($name); $this->logger = $logger; } protected function configure() { $this ->setName('phpci:update') ->setDescription('Update the database to reflect modified models.'); } /** * Generates Model and Store classes by reading database meta data. */ protected function execute(InputInterface $input, OutputInterface $output) { $this->verifyInstalled($output); $output->write('Updating PHPCI database: '); shell_exec(PHPCI_DIR . 'vendor/bin/phinx migrate -c "' . PHPCI_DIR . 'phinx.php"'); $output->writeln('Done!'); } protected function verifyInstalled(OutputInterface $output) { if (!file_exists(PHPCI_DIR . 'PHPCI/config.yml')) { $output->writeln('PHPCI does not appear to be installed.'); $output->writeln('Please install PHPCI via phpci:install instead.'); die; } $content = file_get_contents(PHPCI_DIR . 'PHPCI/config.yml'); if (empty($content)) { $output->writeln('PHPCI does not appear to be installed.'); $output->writeln('Please install PHPCI via phpci:install instead.'); die; } } }