From 0cfbea624eb3d2d7cf2f96840204c418b13372d3 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 3 Nov 2011 19:58:49 +0100 Subject: [PATCH] Add warnings if OpenSSL is not enabled, fixes #84 --- src/Composer/Downloader/FileDownloader.php | 4 ++++ src/Composer/Downloader/GitDownloader.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 32fb186f9..67ee6057d 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -50,6 +50,10 @@ abstract class FileDownloader implements DownloaderInterface echo 'Downloading '.$url.' to '.$fileName.PHP_EOL; + if (0 === strpos($url, 'https:') && !extension_loaded('openssl')) { + throw new \RuntimeException('You must enable the openssl extension to download files via https'); + } + copy($url, $fileName); if (!file_exists($fileName)) { diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 53e30b808..0861737f4 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -36,6 +36,10 @@ class GitDownloader implements DownloaderInterface throw new \InvalidArgumentException('The given package is missing reference information'); } + if (!extension_loaded('openssl')) { + throw new \RuntimeException('You must enable the openssl extension to clone git repositories'); + } + $url = escapeshellarg($package->getSourceUrl()); $ref = escapeshellarg($package->getSourceReference()); system(sprintf('git clone %s %s && cd %2$s && git reset --hard %s', $url, $path, $ref));