public function execute() { $versions = Config::getInstalledPhpVersions(); $currentVersion = Config::getCurrentPhpName(); if (empty($versions)) { return $this->logger->notice("Please install at least one PHP with your prefered version."); } if ($currentVersion === false or !in_array($currentVersion, $versions)) { $this->logger->writeln("* (system)"); } foreach ($versions as $version) { $versionPrefix = Config::getVersionInstallPrefix($version); if ($currentVersion == $version) { $this->logger->writeln($this->formatter->format(sprintf('* %-15s', $version), 'bold')); } else { $this->logger->writeln($this->formatter->format(sprintf(' %-15s', $version), 'bold')); } if ($this->options->dir) { $this->logger->writeln(sprintf(" Prefix: %s", $versionPrefix)); } // TODO: use Build class to get the variants if ($this->options->variants && file_exists($versionPrefix . DIRECTORY_SEPARATOR . 'phpbrew.variants')) { $info = unserialize(file_get_contents($versionPrefix . DIRECTORY_SEPARATOR . 'phpbrew.variants')); echo " Variants: "; echo wordwrap(VariantParser::revealCommandArguments($info), 75, " \\\n "); echo "\n"; } } }
public function execute($buildName) { $prefix = Config::getVersionInstallPrefix($buildName); if (!file_exists($prefix)) { throw new Exception("{$prefix} does not exist."); } $prompter = new \CLIFramework\Prompter(); $answer = $prompter->ask("Are you sure to delete {$buildName}?", array('Y', 'n'), 'Y'); if (strtolower($answer) == "y") { Utils::recursive_unlink($prefix, $this->logger); $this->logger->info("{$buildName} is removed. I hope you're not surprised. :)"); } else { $this->logger->info("Let me guess, you drunk tonight."); } }
public function execute($name) { switch ($name) { case 'root': echo Config::getRoot(); break; case 'home': echo Config::getHome(); break; case 'config-scan': echo Config::getCurrentPhpConfigScanPath(); break; case 'dist': echo Config::getDistFileDir(); break; case 'build': echo Config::getCurrentBuildDir(); break; case 'bin': echo Config::getCurrentPhpBin(); break; case 'include': echo Config::getVersionInstallPrefix(Config::getCurrentPhpName()) . DIRECTORY_SEPARATOR . 'include'; break; case 'extension-src': case 'ext-src': echo Config::getCurrentBuildDir() . DIRECTORY_SEPARATOR . 'ext'; break; case 'extension-dir': case 'ext-dir': case 'ext': echo ini_get('extension_dir'); break; case 'etc': echo Config::getVersionInstallPrefix(Config::getCurrentPhpName()) . DIRECTORY_SEPARATOR . 'etc'; break; } }
/** * Find a installed build by name, * currently a $name is a php version, but in future we may have customized * name for users. * * @param string $name * @return Build */ public static function findByName($name) { $prefix = Config::getVersionInstallPrefix($name); if (file_exists($prefix)) { // a installation exists return new self($name, NULL, $prefix); } return null; }
public function removeByVersion($version, $verbose = false) { $home = Config::getPhpbrewRoot(); $buildPrefix = Config::getVersionInstallPrefix($version); $this->remove($buildPrefix); }