PhpBrew\Config::getRoot PHP Method

getRoot() public static method

public static getRoot ( )
    public static function getRoot()
    {
        if ($root = getenv('PHPBREW_ROOT')) {
            if (!file_exists($root)) {
                mkdir($root, 0755, true);
            }
            return $root;
        }
        if ($home = getenv('HOME')) {
            return $home . DIRECTORY_SEPARATOR . '.phpbrew';
        }
        throw new Exception('Environment variable PHPBREW_ROOT is required');
    }

Usage Example

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