本文整理汇总了PHP中PhpBrew\Config::getInstallPrefix方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::getInstallPrefix方法的具体用法?PHP Config::getInstallPrefix怎么用?PHP Config::getInstallPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpBrew\Config
的用法示例。
在下文中一共展示了Config::getInstallPrefix方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run(Build $build = NULL)
{
$dirs = array();
$dirs[] = Config::getPhpbrewRoot();
$dirs[] = Config::getPhpbrewHome();
$dirs[] = Config::getBuildDir();
$dirs[] = Config::getDistFileDir();
$dirs[] = Config::getVariantsDir();
if ($build) {
$dirs[] = Config::getInstallPrefix() . DIRECTORY_SEPARATOR . $build->getName();
}
foreach ($dirs as $dir) {
if (!file_exists($dir)) {
$this->logger->debug("Creating directory {$dir}");
mkdir($dir, 0755, true);
}
}
}
示例2: execute
public function execute()
{
// $currentVersion;
$root = Config::getPhpbrewRoot();
$home = Config::getPhpbrewHome();
$buildDir = Config::getBuildDir();
$buildPrefix = Config::getInstallPrefix();
// $versionBuildPrefix = Config::getVersionInstallPrefix($version);
// $versionBinPath = Config::getVersionBinPath($version);
if (!file_exists($root)) {
mkdir($root, 0755, true);
}
$paths = array();
$paths[] = $home;
$paths[] = $root;
$paths[] = $buildDir;
$paths[] = $buildPrefix;
foreach ($paths as $p) {
$this->logger->info("Checking directory {$p}");
if (!file_exists($p)) {
$this->logger->info("Creating directory {$p}");
mkdir($p, 0755, true);
}
}
$this->logger->info('Creating .metadata_never_index to prevent SpotLight indexing');
touch($root . DIRECTORY_SEPARATOR . '.metadata_never_index');
// prevent spotlight index here
touch($home . DIRECTORY_SEPARATOR . '.metadata_never_index');
if ($configFile = $this->options->{'config'}) {
if (!file_exists($configFile)) {
return $this->logger->error("{$configFile} does not exist.");
}
$this->logger->debug("Using yaml config from {$configFile}");
copy($configFile, $root . DIRECTORY_SEPARATOR . 'config.yaml');
}
$this->logger->writeln($this->formatter->format("Initialization successfully finished!", 'strong_green'));
$this->logger->writeln($this->formatter->format("<=====================================================>", 'strong_white'));
// write bashrc script to phpbrew home
file_put_contents($home . '/bashrc', $this->getBashScript());
// write phpbrew.fish script to phpbrew home
file_put_contents($home . '/phpbrew.fish', $this->getFishScript());
if (strpos(getenv("SHELL"), "fish") !== false) {
$initConfig = <<<EOS
Paste the following line(s) to the end of your ~/.config/fish/config.fish and start a
new shell, phpbrew should be up and fully functional from there:
source {$home}/phpbrew.fish
EOS;
} else {
$initConfig = <<<EOS
Paste the following line(s) to the end of your ~/.bashrc and start a
new shell, phpbrew should be up and fully functional from there:
source {$home}/bashrc
To enable PHP version info in your shell prompt, please set PHPBREW_SET_PROMPT=1
in your `~/.bashrc` before you source `~/.phpbrew/bashrc`
export PHPBREW_SET_PROMPT=1
EOS;
}
echo <<<EOS
Phpbrew environment is initialized, required directories are created under
{$home}
{$initConfig}
For further instructions, simply run `phpbrew` to see the help message.
Enjoy phpbrew at \$HOME!!
EOS;
$this->logger->writeln($this->formatter->format("<=====================================================>", 'strong_white'));
}
示例3: 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:");
//.........这里部分代码省略.........
示例4: 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);
//.........这里部分代码省略.........