PhpBrew\ReleaseList::getReadyInstance PHP Method

getReadyInstance() public static method

public static getReadyInstance ( OptionResult $options = null )
$options GetOptionKit\OptionResult
    public static function getReadyInstance(OptionResult $options = null)
    {
        static $instance;
        if ($instance) {
            return $instance;
        }
        $instance = new self();
        if ($instance->foundLocalReleaseList()) {
            $instance->setReleases($instance->loadLocalReleaseList());
        } else {
            $instance->fetchRemoteReleaseList($options);
        }
        return $instance;
    }

Usage Example

Example #1
0
 public function execute($version)
 {
     $version = preg_replace('/^php-/', '', $version);
     $releaseList = ReleaseList::getReadyInstance($this->options);
     $releases = $releaseList->getReleases();
     $versionInfo = $releaseList->getVersion($version);
     if (!$versionInfo) {
         throw new Exception("Version {$version} not found.");
     }
     $version = $versionInfo['version'];
     $distUrl = 'http://www.php.net/get/' . $versionInfo['filename'] . '/from/this/mirror';
     if ($mirrorSite = $this->options->mirror) {
         // http://tw1.php.net/distributions/php-5.3.29.tar.bz2
         $distUrl = $mirrorSite . '/distributions/' . $versionInfo['filename'];
     }
     $prepare = new PrepareDirectoryTask($this->logger, $this->options);
     $prepare->run();
     $distFileDir = Config::getDistFileDir();
     $download = new DownloadTask($this->logger, $this->options);
     $targetDir = $download->download($distUrl, $distFileDir, $versionInfo['md5']);
     if (!file_exists($targetDir)) {
         throw new Exception('Download failed.');
     }
     $this->logger->info("Done, please look at: {$targetDir}");
 }
All Usage Examples Of PhpBrew\ReleaseList::getReadyInstance