Example #1
0
 /**
  * {@inheritdoc}
  *
  * @see PlatformCommand::getCurrentEnvironment()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var \Symfony\Component\Console\Helper\ProcessHelper $process */
     $process = $this->getHelper('process');
     $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
     if (!is_dir(Platform::rootDir() . '/docker/fg')) {
         $process->mustRun($output, ['git', 'clone', 'https://github.com/brendangregg/FlameGraph.git', Platform::rootDir() . '/docker/fg']);
     }
     if (!is_dir(Platform::rootDir() . '/docker/xhpfg')) {
         $process->mustRun($output, ['git', 'clone', 'https://github.com/msonnabaum/xhprof-flamegraphs.git', Platform::rootDir() . '/docker/xhpfg']);
     }
     $stack = StacksFactory::getStack(Platform::webDir());
     switch ($stack->type()) {
         case Stacks\Drupal::TYPE:
             $this->stdOut->writeln("<comment>Patching Drupal for xhprof</comment>");
             $patchProcess = new Process('patch -p1 < ' . CLI_ROOT . '/resources/drupal-enable-profiling.patch', Platform::webDir());
             break;
         case Stacks\WordPress::TYPE:
             $this->stdOut->writeln("<comment>Patching WordPress for xhprof</comment>");
             $patchProcess = new Process('patch -p0 < ' . CLI_ROOT . '/resources/wordpress-enable-profiling.patch', Platform::webDir());
             break;
         default:
             throw new \Exception('Stack type not supported yet.');
     }
     $patchProcess->mustRun();
 }
 /**
  * {@inheritdoc}
  *
  * @see PlatformCommand::getCurrentEnvironment()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $stack = StacksFactory::getStack(Platform::webDir());
     switch ($stack->type()) {
         case Stacks\Drupal::TYPE:
             $this->stdOut->writeln("<comment>Removing patch on Drupal for xhprof</comment>");
             $patchProcess = new Process('patch -p1 -R < ' . CLI_ROOT . '/resources/drupal-enable-profiling.patch', Platform::webDir());
             break;
         case Stacks\WordPress::TYPE:
             $this->stdOut->writeln("<comment>Removing patch on WordPress for xhprof</comment>");
             $patchProcess = new Process('patch -p0 -R < ' . CLI_ROOT . '/resources/wordpress-enable-profiling.patch', Platform::webDir());
             break;
         default:
             throw new \Exception('Stack type not supported yet.');
     }
     $patchProcess->mustRun(null);
 }
 /**
  * {@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']);
 }