diff --git a/src/Symfony/Installer/DownloadCommand.php b/src/Symfony/Installer/DownloadCommand.php index 80083bd..b5f3371 100644 --- a/src/Symfony/Installer/DownloadCommand.php +++ b/src/Symfony/Installer/DownloadCommand.php @@ -42,6 +42,7 @@ abstract class DownloadCommand extends Command /** * Returns the type of the downloaded application in a human readable format. * It's mainly used to display readable error messages. + * * @return string */ abstract protected function getDownloadedApplicationType(); @@ -112,7 +113,7 @@ protected function download() $progressBar->setProgress($downloaded); }; - $client = new Client(); + $client = $this->getGuzzleClient(); $client->getEmitter()->attach(new Progress(null, $downloadCallback)); // store the file in a temporary hidden directory with a random name @@ -149,6 +150,25 @@ protected function download() return $this; } + /** + * Returns the Guzzle client configured according to the system environment + * (e.g. it takes into account whether it should use a proxy server or not). + * + * @return Client + */ + protected function getGuzzleClient() + { + $options = array(); + + // check if the client must use a proxy server + if (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy'])) { + $proxy = !empty($_SERVER['http_proxy']) ? $_SERVER['http_proxy'] : $_SERVER['HTTP_PROXY']; + $options['proxy'] = $proxy; + } + + return new Client($options); + } + /** * Extracts the compressed Symfony file (ZIP or TGZ) using the * native operating system commands if available or PHP code otherwise. @@ -207,7 +227,7 @@ protected function extract() } /** - * Checks if environment meets symfony requirements + * Checks if environment meets symfony requirements. * * @return Command */ @@ -298,7 +318,7 @@ protected function getErrorMessage(\Requirement $requirement, $lineSize = 70) } /** - * Generates a good random value for Symfony's 'secret' option + * Generates a good random value for Symfony's 'secret' option. * * @return string */ @@ -340,7 +360,8 @@ protected function getExecutedCommand() /** * Checks whether the given directory is empty or not. * - * @param string $dir the path of the directory to check + * @param string $dir the path of the directory to check + * * @return bool */ protected function isEmptyDirectory($dir) diff --git a/src/Symfony/Installer/NewCommand.php b/src/Symfony/Installer/NewCommand.php index b62e4d6..b7154de 100644 --- a/src/Symfony/Installer/NewCommand.php +++ b/src/Symfony/Installer/NewCommand.php @@ -11,7 +11,6 @@ namespace Symfony\Installer; -use GuzzleHttp\Client; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -130,7 +129,7 @@ protected function checkSymfonyVersionIsInstallable() if (preg_match('/^2\.\d$/', $this->version)) { // Check if we have a minor version in order to retrieve the last patch from symfony.com - $client = new Client(); + $client = $this->getGuzzleClient(); $versionsList = $client->get('http://symfony.com/versions.json')->json(); if ($versionsList && isset($versionsList[$this->version])) {