当前位置: 首页>>代码示例>>PHP>>正文


PHP Config::getHome方法代码示例

本文整理汇总了PHP中PhpBrew\Config::getHome方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::getHome方法的具体用法?PHP Config::getHome怎么用?PHP Config::getHome使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhpBrew\Config的用法示例。


在下文中一共展示了Config::getHome方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
         }
     }
 }
开发者ID:phpbrew,项目名称:phpbrew,代码行数:18,代码来源:PrepareDirectoryTask.php

示例2: 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.");
     }
 }
开发者ID:phpbrew,项目名称:phpbrew,代码行数:21,代码来源:UseCommand.php

示例3: 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');
 }
开发者ID:phpbrew,项目名称:phpbrew,代码行数:38,代码来源:CtagsCommand.php

示例4: 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;
     }
 }
开发者ID:phpbrew,项目名称:phpbrew,代码行数:38,代码来源:PathCommand.php

示例5: 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)"');
 }
开发者ID:phpbrew,项目名称:phpbrew,代码行数:24,代码来源:EnvCommand.php

示例6: execute


//.........这里部分代码省略.........
                // TODO: Move this to PhpConfigPatchTask
                // move config file to target location
                copy($phpConfigPath, $targetConfigPath);
            }
            if (!$this->options->{'no-patch'}) {
                $config = parse_ini_file($targetConfigPath, true);
                $configContent = file_get_contents($targetConfigPath);
                $patched = false;
                if (!isset($config['date']['timezone'])) {
                    $this->logger->info('---> Found date.timezone is not set, patching...');
                    // Replace current timezone
                    if ($timezone = ini_get('date.timezone')) {
                        $this->logger->info("---> Found date.timezone, patching config timezone with {$timezone}");
                        $configContent = preg_replace('/^;?date.timezone\\s*=\\s*.*/im', "date.timezone = {$timezone}", $configContent);
                    }
                    $patched = true;
                }
                if (!isset($config['phar']['readonly'])) {
                    $pharReadonly = ini_get('phar.readonly');
                    // 0 or "" means readonly is disabled manually
                    if (!$pharReadonly) {
                        $this->logger->info('---> Disabling phar.readonly option.');
                        $configContent = preg_replace('/^;?phar.readonly\\s*=\\s*.*/im', 'phar.readonly = 0', $configContent);
                    }
                }
                // turn off detect_encoding for 5.3
                if ($build->compareVersion('5.4') < 0) {
                    $this->logger->info("---> Turn off detect_encoding for php 5.3.*");
                    $configContent = $configContent . "\ndetect_unicode = Off\n";
                }
                file_put_contents($targetConfigPath, $configContent);
            }
        }
        if ($build->isEnabledVariant('pear')) {
            $this->logger->info('Initializing pear config...');
            $home = Config::getHome();
            @mkdir("{$home}/tmp/pear/temp", 0755, true);
            @mkdir("{$home}/tmp/pear/cache_dir", 0755, true);
            @mkdir("{$home}/tmp/pear/download_dir", 0755, true);
            system("pear config-set temp_dir {$home}/tmp/pear/temp");
            system("pear config-set cache_dir {$home}/tmp/pear/cache_dir");
            system("pear config-set download_dir {$home}/tmp/pear/download_dir");
            $this->logger->info('Enabling pear auto-discover...');
            system('pear config-set auto_discover 1');
        }
        $this->logger->debug('Source directory: ' . $targetDir);
        $buildName = $build->getName();
        $this->logger->info("Congratulations! Now you have PHP with {$version} as {$buildName}");
        if ($build->isEnabledVariant('pdo') && $build->isEnabledVariant('mysql')) {
            echo <<<EOT

* We found that you enabled 'mysql' variant, you might need to setup your
  'pdo_mysql.default_socket' or 'mysqli.default_socket' in your php.ini file.

EOT;
        }
        if (isset($targetConfigPath)) {
            echo <<<EOT

* To configure your installed PHP further, you can edit the config file at
    {$targetConfigPath}

EOT;
        }
        // If the bashrc file is not found, it means 'init' command didn't get
        // a chance to be executed.
        if (!file_exists(Config::getHome() . DIRECTORY_SEPARATOR . 'bashrc')) {
            echo <<<EOT

* WARNING:
  You haven't run 'phpbrew init' yet! Be sure to setup your phpbrew to use your own php(s)
  Please run 'phpbrew init' to setup your phpbrew in place.

EOT;
        }
        // If the environment variable is not defined, it means users didn't
        // setup ther .bashrc or .zshrc
        if (!getenv('PHPBREW_HOME')) {
            echo <<<EOT

* WARNING:
  You haven't setup your .bashrc file to load phpbrew shell script yet!
  Please run 'phpbrew init' to see the steps!

EOT;
        }
        echo <<<EOT

To use the newly built PHP, try the line(s) below:

    \$ phpbrew use {$buildName}

Or you can use switch command to switch your default php to {$buildName}:

    \$ phpbrew switch {$buildName}

Enjoy!

EOT;
    }
开发者ID:phpbrew,项目名称:phpbrew,代码行数:101,代码来源:InstallCommand.php

示例7: 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'));
    }
开发者ID:phpbrew,项目名称:phpbrew,代码行数:89,代码来源:InitCommand.php


注:本文中的PhpBrew\Config::getHome方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。