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}");
}