예제 #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();
 }
예제 #2
0
 public function configure()
 {
     $this->fs->copy(CLI_ROOT . '/resources/stacks/wordpress/wp-config.php', Platform::webDir() . '/wp-config.php', true);
     $this->fs->remove(Platform::webDir() . '/wp-confg-sample.php');
     $this->fs->copy(CLI_ROOT . '/resources/stacks/wordpress/wp-config.local.php', Platform::sharedDir() . '/wp-config.local.php');
     $localSettings = file_get_contents(Platform::sharedDir() . '/wp-config.local.php');
     $localSettings = str_replace('{{ salts }}', $this->salts(), $localSettings);
     $localSettings = str_replace('{{ container_name }}', $this->containerName, $localSettings);
     $localSettings = str_replace('{{ project_domain }}', $this->projectName . '.' . $this->projectTld, $localSettings);
     file_put_contents(Platform::sharedDir() . '/wp-config.local.php', $localSettings);
     // Relink if missing.
     if (!$this->fs->exists(Platform::webDir() . '/wp-config.local.php')) {
         $this->fs->symlink('../shared/wp-config.local.php', Platform::webDir() . '/wp-config.local.php');
     }
 }
예제 #3
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);
 }
예제 #4
0
 /**
  * {@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);
 }
예제 #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
 /**
  * Write a drushrc
  */
 public function drushrc()
 {
     // @todo: Check if drushrc.php exists, load in any $conf changes.
     switch ($this->version) {
         case DrupalStackHelper::DRUPAL7:
             $this->fs->copy(CLI_ROOT . '/resources/stacks/drupal7/drushrc.php', Platform::sharedDir() . '/drushrc.php', true);
             break;
         case DrupalStackHelper::DRUPAL8:
             $this->fs->copy(CLI_ROOT . '/resources/stacks/drupal8/drushrc.php', Platform::sharedDir() . '/drushrc.php', true);
             break;
         default:
             throw new \Exception('Unsupported version of Drupal. Write a pull reuqest!');
     }
     // Replace template variables.
     $localSettings = file_get_contents(Platform::sharedDir() . '/drushrc.php');
     // @todo this expects proxy to be running.
     $localSettings = str_replace('{{ project_domain }}', $this->projectName . '.' . $this->projectTld, $localSettings);
     file_put_contents(Platform::sharedDir() . '/drushrc.php', $localSettings);
     $this->fs->symlink('../../../shared/drushrc.php', Platform::webDir() . '/sites/default/drushrc.php');
 }
예제 #7
0
 protected function discoverBehatYml()
 {
     $depth = $this->stdIn->getOption('depth');
     $scanDirs = [Platform::sharedDir(), Platform::webDir()];
     if (is_dir(Platform::repoDir())) {
         $scanDirs[] = Platform::repoDir();
     }
     if (is_dir(Platform::testsDir())) {
         $scanDirs[] = Platform::testsDir();
     }
     $extraDir = $this->stdIn->getOption('folder');
     if ($extraDir && is_dir($extraDir)) {
         $scanDirs[] = $extraDir;
     }
     $finder = new Finder();
     $finder->files()->in($scanDirs)->depth("< {$depth}")->name('behat.yml');
     return $finder;
 }
예제 #8
0
 /**
  * {@inheritdoc}
  *
  * @see PlatformCommand::getCurrentEnvironment()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $processBuilder = ProcessBuilder::create(['drush', $input->getArgument('cmd'), '--root=' . Platform::webDir(), '--uri=' . Platform::projectName() . '.' . Platform::projectTld()]);
     passthru($processBuilder->getProcess()->getCommandLine());
 }
예제 #9
0
 public function testWebRoot()
 {
     mkdir(Platform::webDir());
     $this->assertTrue(is_dir(self::$tmpName . '/www'));
 }