Пример #1
0
 protected function checkProjectRequired()
 {
     if ($this->projectRequired && empty(Config::get())) {
         $this->getApplication()->find('init')->run($this->stdIn, $this->stdOut);
         exit(1);
     }
 }
Пример #2
0
 public function testProjectName()
 {
     $this->assertEquals('phpunit', Platform::projectName());
     // Change values
     file_put_contents(Platform::rootDir() . '/' . Config::PLATFORM_CONFIG, '');
     Config::reset();
     $this->assertNull(Platform::projectName());
 }
Пример #3
0
 public function testSet()
 {
     Config::set('stack', 'wordpress');
     $this->assertEquals('wordpress', Config::get('stack'));
     Config::reset();
     $this->assertArrayNotHasKey('stack', Config::get());
     Config::set('stack', 'wordpress');
     Config::write();
     Config::reset();
     $this->assertEquals('wordpress', Config::get('stack'));
 }
Пример #4
0
 /**
  * {@inheritdoc}
  *
  * @see PlatformCommand::getCurrentEnvironment()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->stdOut->writeln("<info>Syncing Platform.sh environment database to local</info>");
     /** @var \Symfony\Component\Console\Helper\ProcessHelper $process */
     $process = $this->getHelper('process');
     // If this is a Platform.sh project, get latest dump.
     // @todo: add proper provider integration
     if (Config::get('id')) {
         $process->mustRun($this->stdOut, ['platform', 'sql-dump']);
     }
     $cd = getcwd();
     chdir(Platform::webDir());
     $process->run($this->stdOut, 'drush sqlc < ' . $input->getArgument('file'));
     chdir($cd);
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $composeConfig = new ComposeConfig();
     // Create docker folder in project.
     try {
         $composeConfig->ensureDirectories();
     } catch (IOException $e) {
         $this->stdOut->writeln("<error>Error while trying to create docker-compose directories.</error>");
         exit(1);
     }
     $composeConfig->copyImages();
     $composeConfig->copyConfigs();
     $composeContainers = new ComposeContainers(Platform::rootDir(), Config::get('name'));
     // @todo: With #20 and making tool provider aware, read those configs. Or push those configs to main.
     if (isset(Config::get()['services'])) {
         foreach (Config::get('services') as $service) {
             switch ($service) {
                 case 'redis':
                     $composeContainers->addRedis();
                     break;
                 case 'solr':
                     $composeContainers->addSolr();
                     break;
                 case 'memcached':
                     $composeContainers->addMemcached();
                     break;
                 case 'blackfire':
                     $composeContainers->addBlackfire();
                     break;
             }
         }
     }
     $composeConfig->writeDockerCompose($composeContainers);
     $stack = Toolstack::inspect(Platform::webDir());
     if ($stack) {
         $this->stdOut->writeln("<comment>Configuring stack:</comment> " . $stack->type());
         StacksFactory::configure($stack->type());
     }
     $this->stdOut->writeln('<info>Building the containers</info>');
     Compose::build();
     $this->stdOut->writeln('<info>Bringing up the containers</info>');
     Compose::up(['-d']);
 }
Пример #6
0
 /**
  * @inheritdoc
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     if (empty(Config::get())) {
         $this->cwd = getcwd();
         /** @var QuestionHelper $helper */
         $helper = $this->getHelper('question');
         $output->writeln("<comment>Current directory: {$this->cwd}");
         $question = new ConfirmationQuestion("<info>There isn't a project here, create one? [Y,n] </info>");
         if ($helper->ask($input, $output, $question)) {
             Config::set('alias-group', basename($this->cwd));
             Config::set('name', basename($this->cwd));
             Config::set('path', $this->cwd);
             if (!Config::write($this->cwd)) {
                 throw new \Exception('There was an error writing the platform configuration.');
             }
         } else {
             exit(1);
         }
     }
     parent::initialize($input, $output);
 }
Пример #7
0
 public function addBlackfire()
 {
     $this->config['blackfire'] = ['image' => 'blackfire/blackfire', 'ports' => ['8707'], 'environment' => ['BLACKFIRE_SERVER_ID' => Config::get('blackfire_server_id'), 'BLACKFIRE_SERVER_TOKEN' => Config::get('blackfire_server_token'), 'BLACKFIRE_LOG_LEVEL' => 4]];
     $this->config['phpfpm']['links'][] = 'blackfire';
 }