PhpBrew\Config::getHome PHP Method

getHome() public static method

Return optional home directory.
public static getHome ( ) : string
return string
    public static function getHome()
    {
        if ($custom = getenv('PHPBREW_HOME')) {
            if (!file_exists($custom)) {
                mkdir($custom, 0755, true);
            }
            return $custom;
        }
        if ($home = getenv('HOME')) {
            $path = $home . DIRECTORY_SEPARATOR . '.phpbrew';
            if (!file_exists($path)) {
                mkdir($path, 0755, true);
            }
            return $path;
        }
        throw new Exception('Environment variable PHPBREW_HOME or HOME is required');
    }

Usage Example

Example #1
0
 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);
         }
     }
 }
All Usage Examples Of PhpBrew\Config::getHome