本文整理汇总了PHP中PhpBrew\Config::getRoot方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::getRoot方法的具体用法?PHP Config::getRoot怎么用?PHP Config::getRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpBrew\Config
的用法示例。
在下文中一共展示了Config::getRoot方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($appName)
{
$apps = AppStore::all();
if (!isset($apps[$appName])) {
throw new Exception("App {$appName} not found.");
}
$app = $apps[$appName];
$targetDir = Config::getRoot() . DIRECTORY_SEPARATOR . 'bin';
$target = $targetDir . DIRECTORY_SEPARATOR . $app['as'];
DownloadFactory::getInstance($this->logger, $this->options)->download($app['url'], $target);
$this->logger->info('Changing permissions to 0755');
if ($mod = $this->options->chmod) {
chmod($target, octdec($mod));
} else {
chmod($target, 0755);
}
$this->logger->info("Downloaded at {$target}");
}
示例2: run
public function run(Build $build = null)
{
$dirs = array();
$dirs[] = Config::getRoot();
$dirs[] = Config::getHome();
$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);
}
}
}
示例3: execute
public function execute($buildName)
{
if (!$buildName) {
// This exception is used for tracing tests
throw new Exception('build name is required.');
}
// this block is important for tests only
$root = Config::getRoot();
$home = Config::getHome();
if (!file_exists("{$root}/php/{$buildName}")) {
throw new Exception("build {$buildName} doesn't exist.");
}
putenv("PHPBREW_ROOT={$root}");
putenv("PHPBREW_HOME={$home}");
putenv("PHPBREW_PHP={$buildName}") or die('putenv failed');
putenv("PHPBREW_PATH={$root}/php/{$buildName}/bin");
putenv("PHPBREW_BIN={$home}/bin");
if (!getenv('TRAVIS')) {
$this->logger->warning("You should not see this, if you see this, it means you didn't load the ~/.phpbrew/bashrc script, please check if bashrc is sourced in your shell.");
}
}
示例4: execute
public function execute($versionName = null)
{
$args = func_get_args();
array_shift($args);
// $currentVersion;
$root = Config::getRoot();
$home = Config::getHome();
if ($versionName) {
$sourceDir = Config::getBuildDir() . DIRECTORY_SEPARATOR . $versionName;
} else {
if (!getenv('PHPBREW_PHP')) {
$this->logger->error('Error: PHPBREW_PHP environment variable is not defined.');
$this->logger->error(' This command requires you specify a PHP version from your build list.');
$this->logger->error(" And it looks like you haven't switched to a version from the builds that were built with PHPBrew.");
$this->logger->error('Suggestion: Please install at least one PHP with your prefered version and switch to it.');
return false;
}
$sourceDir = Config::getCurrentBuildDir();
}
if (!file_exists($sourceDir)) {
return $this->logger->error("{$sourceDir} does not exist.");
}
$this->logger->info('Scanning ' . $sourceDir);
$cmd = new CommandBuilder('ctags');
$cmd->arg('-R');
$cmd->arg('-a');
$cmd->arg('-h');
$cmd->arg('.c.h.cpp');
$cmd->arg($sourceDir . DIRECTORY_SEPARATOR . 'main');
$cmd->arg($sourceDir . DIRECTORY_SEPARATOR . 'ext');
$cmd->arg($sourceDir . DIRECTORY_SEPARATOR . 'Zend');
foreach ($args as $a) {
$cmd->arg($a);
}
$this->logger->debug($cmd->__toString());
$cmd->execute();
$this->logger->info('Done');
}
示例5: execute
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;
}
}
示例6: execute
public function execute($buildName = null)
{
// get current version
if (!$buildName) {
$buildName = getenv('PHPBREW_PHP');
}
// $currentVersion;
$root = Config::getRoot();
$home = Config::getHome();
$lookup = getenv('PHPBREW_LOOKUP_PREFIX');
$this->logger->writeln("export PHPBREW_ROOT={$root}");
$this->logger->writeln("export PHPBREW_HOME={$home}");
$this->logger->writeln("export PHPBREW_LOOKUP_PREFIX={$lookup}");
if ($buildName !== false) {
// checking php version existence
$targetPhpBinPath = Config::getVersionBinPath($buildName);
if (is_dir($targetPhpBinPath)) {
echo 'export PHPBREW_PHP=' . $buildName . "\n";
echo 'export PHPBREW_PATH=' . ($buildName ? Config::getVersionBinPath($buildName) : '') . "\n";
}
}
$this->logger->writeln('# Run this command to configure your shell:');
$this->logger->writeln('# # eval "$(phpbrew env)"');
}
示例7: generateInitD
protected function generateInitD($buildName, $fpmBin)
{
$root = Config::getRoot();
$phpdir = "{$root}/php/{$buildName}";
$pidFile = $phpdir . '/var/run/php-fpm.pid';
$config = <<<EOS
#!/bin/sh
### BEGIN INIT INFO
# Provides: phpbrew-fpm
# Required-Start: \$remote_fs \$network
# Required-Stop: \$remote_fs \$network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts phpbrew-fpm
# Description: Starts The PHP FastCGI Process Manager Daemon
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="PHPBrew FastCGI Process Manager"
NAME=phpbrew-fpm
PHP_VERSION={$buildName}
PHPBREW_ROOT={$root}
CONFFILE={$phpdir}/etc/php-fpm.conf
DAEMON={$fpmBin}
DAEMON_ARGS="--daemonize --fpm-config \$CONFFILE --pid {$pidFile}"
PIDFILE={$pidFile}
TIMEOUT=30
SCRIPTNAME=/etc/init.d/\$NAME
# Exit if the package is not installed
[ -x "\$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/\$NAME ] && . /etc/default/\$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function to check the correctness of the config file
#
do_check()
{
# FIXME
# /usr/lib/php/phpbrew-fpm-checkconf || return 1
return 0
}
#
# Function that starts the daemon/service
#
do_start()
{
\t# Return
\t# 0 if daemon has been started
\t# 1 if daemon was already running
\t# 2 if daemon could not be started
\tstart-stop-daemon --start --quiet --pidfile \$PIDFILE --exec \$DAEMON --test > /dev/null \\
\t\t|| return 1
\tstart-stop-daemon --start --quiet --pidfile \$PIDFILE --exec \$DAEMON -- \\
\t\t\$DAEMON_ARGS 2>/dev/null \\
\t\t|| return 2
\t# Add code here, if necessary, that waits for the process to be ready
\t# to handle requests from services started subsequently which depend
\t# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
\t# Return
\t# 0 if daemon has been stopped
\t# 1 if daemon was already stopped
\t# 2 if daemon could not be stopped
\t# other if a failure occurred
\tstart-stop-daemon --stop --quiet --retry=QUIT/\$TIMEOUT/TERM/5/KILL/5 --pidfile \$PIDFILE --name \$NAME
\tRETVAL="\$?"
\t[ "\$RETVAL" = 2 ] && return 2
\t# Wait for children to finish too if this is a daemon that forks
\t# and if the daemon is only ever run from this initscript.
\t# If the above conditions are not satisfied then add some other code
\t# that waits for the process to drop all resources that could be
\t# needed by services started subsequently. A last resort is to
\t# sleep for some time.
\tstart-stop-daemon --stop --quiet --oknodo --retry=0/30/TERM/5/KILL/5 --exec \$DAEMON
\t[ "\$?" = 2 ] && return 2
\t# Many daemons don't delete their pidfiles when they exit.
\trm -f \$PIDFILE
\treturn "\$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
//.........这里部分代码省略.........
示例8: execute
public function execute()
{
// $currentVersion;
$root = $this->options->root ?: Config::getRoot();
$home = Config::getHome();
$buildDir = Config::getBuildDir();
$buildPrefix = Config::getInstallPrefix();
// $versionBuildPrefix = Config::getVersionInstallPrefix($version);
// $versionBinPath = Config::getVersionBinPath($version);
$this->logger->info("Using root: {$root}");
if (!file_exists($root)) {
mkdir($root, 0755, true);
}
$paths = array();
$paths[] = $home;
$paths[] = $root;
$paths[] = $root . DIRECTORY_SEPARATOR . 'register';
$paths[] = $buildDir;
$paths[] = $buildPrefix;
foreach ($paths as $p) {
$this->logger->debug("Checking directory {$p}");
if (!file_exists($p)) {
$this->logger->debug("Creating directory {$p}");
mkdir($p, 0755, true);
} else {
$this->logger->debug("Directory {$p} is already created.");
}
}
$this->logger->debug('Creating .metadata_never_index to prevent SpotLight indexing');
$indexFiles = array($root . DIRECTORY_SEPARATOR . '.metadata_never_index', $home . DIRECTORY_SEPARATOR . '.metadata_never_index');
foreach ($indexFiles as $indexFile) {
if (!file_exists($indexFile)) {
touch($indexFile);
// prevent spotlight index here
}
}
if ($configFile = $this->options->{'config'}) {
if (!file_exists($configFile)) {
return $this->logger->error("config file '{$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->getBashScriptPath());
// write phpbrew.fish script to phpbrew home
file_put_contents($home . '/phpbrew.fish', $this->getFishScriptPath());
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
To enable .phpbrewrc file searching, please export the following variable:
export PHPBREW_RC_ENABLE=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'));
}
示例9: removeByVersion
public function removeByVersion($version, $verbose = false)
{
$home = Config::getRoot();
$buildPrefix = Config::getVersionInstallPrefix($version);
$this->remove($buildPrefix);
}