/** * @inheritdoc */ protected function initialize(InputInterface $input, OutputInterface $output) { // Validate we can run. if ($this->platformConfig === null) { $output->writeln('<error>Must run command within a Platform.sh project</error>'); exit(1); } $this->projectPath = LocalProject::getProjectRoot(); $this->projectName = Platform::projectName(); $this->stdOut = $output; $this->stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; $this->stdIn = $input; self::$interactive = $input->isInteractive(); }
/** * @return string|false */ public function getProjectRoot() { if (!isset(self::$projectRoot)) { $this->debug('Finding the project root based on the CWD'); self::$projectRoot = $this->localProject->getProjectRoot(); $this->debug(self::$projectRoot ? 'Project root found: ' . self::$projectRoot : 'Project root not found'); } return self::$projectRoot; }
/** * Builds Docker Compose YML file. * * @param $name */ function __construct($name) { $this->path = LocalProject::getProjectRoot(); $this->name = $name; // Add required containers. $this->addPhpFpm(); $this->addDatabase(); $this->addWebserver(); }
/** * {@inheritdoc} * * @see PlatformCommand::getCurrentEnvironment() */ protected function execute(InputInterface $input, OutputInterface $output) { $xhpfg = LocalProject::getProjectRoot() . '/docker/xhpfg/xhprof-sample-to-flamegraph-stacks'; $fg = LocalProject::getProjectRoot() . '/docker/fg/flamegraph.pl'; $xhprof = LocalProject::getProjectRoot() . '/xhprof'; $graphName = $input->getArgument('filename'); $graphDestination = LocalProject::getProjectRoot() . '/' . $graphName . '.svg'; exec("{$xhpfg} {$xhprof} | {$fg} > {$graphDestination}"); $url = 'file://' . $graphDestination; $this->openUrl($url); }
public function testGetProjectRoot() { $tempDir = $this->root->getName(); $testDir = tempnam($tempDir, ''); unlink($testDir); mkdir("{$testDir}/1/2/3/4/5", 0755, true); $expectedRoot = "{$testDir}/1"; touch("{$expectedRoot}/.platform-project"); chdir($testDir); $this->assertFalse(LocalProject::getProjectRoot()); chdir($expectedRoot); $this->assertEquals($expectedRoot, LocalProject::getProjectRoot()); chdir("{$testDir}/1/2/3/4/5"); $this->assertEquals($expectedRoot, LocalProject::getProjectRoot()); }
/** * {@inheritdoc} * * @see PlatformCommand::getCurrentEnvironment() */ protected function execute(InputInterface $input, OutputInterface $output) { /** @var ShellHelper $shell */ $shell = $this->getHelper('shell'); $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); $shell->setOutput($output); if (!is_dir(LocalProject::getProjectRoot() . '/docker/fg')) { $shell->execute(['git', 'clone', 'https://github.com/brendangregg/FlameGraph.git', LocalProject::getProjectRoot() . '/docker/fg']); } if (!is_dir(LocalProject::getProjectRoot() . '/docker/xhpfg')) { $shell->execute(['git', 'clone', 'https://github.com/msonnabaum/xhprof-flamegraphs.git', LocalProject::getProjectRoot() . '/docker/xhpfg']); } $this->stdOut->writeln("<comment>Patching Drupal for xhprof</comment>"); $process = new Process('patch -p1 < ' . CLI_ROOT . '/resources/drupal-enable-profiling.patch', Platform::webDir()); $process->mustRun(null); }
/** * @return string|false */ public function getProjectRoot() { if (empty(self::$projectRoot)) { self::$projectRoot = LocalProject::getProjectRoot(); } return self::$projectRoot; }
public static function webDir() { return LocalProject::getProjectRoot() . '/' . LocalProject::WEB_ROOT; }
/** * @return string|false */ protected function getProjectRoot() { return $this->projectRoot ?: LocalProject::getProjectRoot(); }
/** * */ public function __construct() { $this->resourcesDir = CLI_ROOT . '/resources'; $this->projectPath = LocalProject::getProjectRoot(); $this->fs = new Filesystem(); }