本文整理汇总了PHP中PhpBrew\Config::setPhpbrewRoot方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::setPhpbrewRoot方法的具体用法?PHP Config::setPhpbrewRoot怎么用?PHP Config::setPhpbrewRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpBrew\Config
的用法示例。
在下文中一共展示了Config::setPhpbrewRoot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($version)
{
$distUrl = NULL;
$versionInfo = array();
$releaseList = ReleaseList::getReadyInstance();
$versionDslParser = new VersionDslParser();
$clean = new MakeTask($this->logger, $this->options);
$clean->setQuiet();
if ($root = $this->options->root) {
Config::setPhpbrewRoot($root);
}
if ($home = $this->options->home) {
Config::setPhpbrewHome($home);
}
if ('latest' === strtolower($version)) {
$version = $releaseList->getLatestVersion();
}
// this should point to master or the latest version branch yet to be released
if ('next' === strtolower($version)) {
$version = "github.com/php/php-src:master";
}
if ($info = $versionDslParser->parse($version)) {
$version = $info['version'];
$distUrl = $info['url'];
// always redownload when installing from github master
// beware to keep this behavior after clean up the TODO below
$this->options['force']->setValue(true);
} else {
// TODO ↓ clean later ↓ d.d.d versions should be part of the DSL too
$version = preg_replace('/^php-/', '', $version);
$versionInfo = $releaseList->getVersion($version);
if (!$versionInfo) {
throw new Exception("Version {$version} not found.");
}
$version = $versionInfo['version'];
$distUrlPolicy = new DistributionUrlPolicy();
if ($this->options->mirror) {
$distUrlPolicy->setMirrorSite($this->options->mirror);
}
$distUrl = $distUrlPolicy->buildUrl($version, $versionInfo['filename']);
}
// get options and variants for building php
// and skip the first argument since it's the target version.
$args = func_get_args();
array_shift($args);
// shift the version name
$semanticOptions = $this->parseSemanticOptions($args);
$buildAs = isset($semanticOptions['as']) ? $semanticOptions['as'] : $this->options->name;
$buildLike = isset($semanticOptions['like']) ? $semanticOptions['like'] : $this->options->like;
// convert patch to realpath
if ($this->options->patch) {
$patchPaths = array();
foreach ($this->options->patch as $patch) {
/** @var \SplFileInfo $patch */
$patchPath = realpath($patch);
if ($patchPath !== false) {
$patchPaths[(string) $patch] = $patchPath;
}
}
// rewrite patch paths
$this->options->keys['patch']->value = $patchPaths;
}
// Initialize the build object, contains the information to build php.
$build = new Build($version, $buildAs);
$installPrefix = Config::getInstallPrefix() . DIRECTORY_SEPARATOR . $build->getName();
if (!file_exists($installPrefix)) {
mkdir($installPrefix, 0755, true);
}
$build->setInstallPrefix($installPrefix);
// find inherited variants
if ($buildLike) {
if ($parentBuild = Build::findByName($buildLike)) {
$build->loadVariantInfo($parentBuild->settings->toArray());
}
}
$msg = "===> phpbrew will now build {$build->getVersion()}";
if ($buildLike) {
$msg .= ' using variants from ' . $buildLike;
}
if (isset($semanticOptions['using'])) {
$msg .= ' plus custom variants: ' . join(', ', $semanticOptions['using']);
$args = array_merge($args, $semanticOptions['using']);
}
if ($buildAs) {
$msg .= ' as ' . $buildAs;
}
$this->logger->info($msg);
if (!empty($args)) {
$this->logger->debug("---> Parsing variants from command arguments '" . join(' ', $args) . "'");
}
// ['extra_options'] => the extra options to be passed to ./configure command
// ['enabled_variants'] => enabeld variants
// ['disabled_variants'] => disabled variants
$variantInfo = VariantParser::parseCommandArguments($args);
$build->loadVariantInfo($variantInfo);
// load again
// assume +default variant if no build config is given and warn about that
if (!$variantInfo['enabled_variants']) {
$build->setBuildSettings(new DefaultBuildSettings());
$this->logger->notice("You haven't set any variant. A default set of extensions will be installed for the minimum requirement:");
//.........这里部分代码省略.........
示例2: execute
public function execute($version)
{
if (extension_loaded('posix') && posix_getuid() === 0) {
$this->logger->warn("*WARNING* You're runing phpbrew as root/sudo. Unless you're going to install\nsystem-wide phpbrew or this might cause problems.");
sleep(3);
}
$distUrl = null;
$versionInfo = array();
$releaseList = ReleaseList::getReadyInstance($this->options);
$versionDslParser = new VersionDslParser();
$clean = new MakeTask($this->logger, $this->options);
$clean->setQuiet();
if ($root = $this->options->root) {
Config::setPhpbrewRoot($root);
}
if ($home = $this->options->home) {
Config::setPhpbrewHome($home);
}
if ('latest' === strtolower($version)) {
$version = $releaseList->getLatestVersion();
}
// this should point to master or the latest version branch yet to be released
if ('next' === strtolower($version)) {
$version = 'github.com/php/php-src:master';
}
if ($info = $versionDslParser->parse($version)) {
$version = $info['version'];
$distUrl = $info['url'];
// always redownload when installing from github master
// beware to keep this behavior after clean up the TODO below
$this->options['force']->setValue(true);
} else {
// TODO ↓ clean later ↓ d.d.d versions should be part of the DSL too
$version = preg_replace('/^php-/', '', $version);
$versionInfo = $releaseList->getVersion($version);
if (!$versionInfo) {
throw new Exception("Version {$version} not found.");
}
$version = $versionInfo['version'];
$distUrlPolicy = new DistributionUrlPolicy();
if ($this->options->mirror) {
$distUrlPolicy->setMirrorSite($this->options->mirror);
}
$distUrl = $distUrlPolicy->buildUrl($version, $versionInfo['filename'], $versionInfo['museum']);
}
// get options and variants for building php
// and skip the first argument since it's the target version.
$args = func_get_args();
array_shift($args);
// shift the version name
$semanticOptions = $this->parseSemanticOptions($args);
$buildAs = isset($semanticOptions['as']) ? $semanticOptions['as'] : $this->options->name;
$buildLike = isset($semanticOptions['like']) ? $semanticOptions['like'] : $this->options->like;
// convert patch to realpath
if ($this->options->patch) {
$patchPaths = array();
foreach ($this->options->patch as $patch) {
/* @var \SplFileInfo $patch */
$patchPath = realpath($patch);
if ($patchPath !== false) {
$patchPaths[(string) $patch] = $patchPath;
}
}
// rewrite patch paths
$this->options->keys['patch']->value = $patchPaths;
}
// Initialize the build object, contains the information to build php.
$build = new Build($version, $buildAs);
$installPrefix = Config::getInstallPrefix() . DIRECTORY_SEPARATOR . $build->getName();
if (!file_exists($installPrefix)) {
mkdir($installPrefix, 0755, true);
}
$build->setInstallPrefix($installPrefix);
// find inherited variants
if ($buildLike) {
if ($parentBuild = Build::findByName($buildLike)) {
$this->logger->info("===> Loading build settings from {$buildLike}");
$build->loadVariantInfo($parentBuild->settings->toArray());
}
}
$msg = "===> phpbrew will now build {$build->getVersion()}";
if ($buildLike) {
$msg .= ' using variants from ' . $buildLike;
}
if (isset($semanticOptions['using'])) {
$msg .= ' plus custom variants: ' . implode(', ', $semanticOptions['using']);
$args = array_merge($args, $semanticOptions['using']);
}
if ($buildAs) {
$msg .= ' as ' . $buildAs;
}
$this->logger->info($msg);
if (!empty($args)) {
$this->logger->debug("---> Parsing variants from command arguments '" . implode(' ', $args) . "'");
}
// ['extra_options'] => the extra options to be passed to ./configure command
// ['enabled_variants'] => enabeld variants
// ['disabled_variants'] => disabled variants
$variantInfo = VariantParser::parseCommandArguments($args);
$build->loadVariantInfo($variantInfo);
//.........这里部分代码省略.........