diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php
index 58c10e1d8..b089a8b32 100755
--- a/src/Composer/Json/JsonFile.php
+++ b/src/Composer/Json/JsonFile.php
@@ -85,7 +85,7 @@ class JsonFile
$json = file_get_contents($this->path);
}
} catch (TransportException $e) {
- throw new \RuntimeException('Could not read '.$this->path.', either you or the remote host is probably offline'."\n\n".$e->getMessage());
+ throw new \RuntimeException($e->getMessage());
} catch (\Exception $e) {
throw new \RuntimeException('Could not read '.$this->path."\n\n".$e->getMessage());
}
diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php
index d1d1754ae..2c4849243 100644
--- a/src/Composer/Repository/ComposerRepository.php
+++ b/src/Composer/Repository/ComposerRepository.php
@@ -101,6 +101,7 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
$this->cache->write('packages.json', json_encode($data));
} catch (\Exception $e) {
if ($contents = $this->cache->read('packages.json')) {
+ $this->io->write(''.$e->getMessage().'');
$this->io->write(''.$this->url.' could not be loaded, package information was loaded from the local cache and may be out of date');
$data = json_decode($contents, true);
} else {
diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php
index 36b2115a8..e82313033 100644
--- a/src/Composer/Util/RemoteFilesystem.php
+++ b/src/Composer/Util/RemoteFilesystem.php
@@ -101,7 +101,15 @@ class RemoteFilesystem
$this->io->write(" Downloading: connection...", false);
}
- $result = @file_get_contents($fileUrl, false, $ctx);
+ $errorMessage = null;
+ set_error_handler(function ($code, $msg) use (&$errorMessage) {
+ $errorMessage = preg_replace('{^file_get_contents\(.+?\): }', '', $msg);
+ if (!ini_get('allow_url_fopen')) {
+ $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
+ }
+ });
+ $result = file_get_contents($fileUrl, false, $ctx);
+ restore_error_handler();
// fix for 5.4.0 https://bugs.php.net/bug.php?id=61336
if (!empty($http_response_header[0]) && preg_match('{^HTTP/\S+ 404}i', $http_response_header[0])) {
@@ -148,7 +156,7 @@ class RemoteFilesystem
}
if (false === $this->result) {
- throw new TransportException('The "'.$fileUrl.'" file could not be downloaded');
+ throw new TransportException('The "'.$fileUrl.'" file could not be downloaded: '.$errorMessage);
}
}