Browse Source

Added php.ini path to error message #1052

Mikołaj Kopras 12 years ago
parent
commit
534fe36149
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/Composer/Downloader/ZipDownloader.php

+ 12 - 1
src/Composer/Downloader/ZipDownloader.php

@@ -34,7 +34,17 @@ class ZipDownloader extends ArchiveDownloader
     protected function extract($file, $path)
     {
         if (!class_exists('ZipArchive')) {
-            $error = 'You need the zip extension enabled to use the ZipDownloader';
+            // php.ini path is added to the error message to help users find the correct file
+            $iniPath = php_ini_loaded_file();
+
+            if ($iniPath) {
+                $iniMessage = 'The php.ini used by your command-line PHP is: ' . $iniPath;
+            } else {
+                $iniMessage = 'A php.ini file does not exist. You will have to create one.';
+            }
+
+            $error = "You need the zip extension enabled to use the ZipDownloader.\n".
+                $iniMessage;
 
             // try to use unzip on *nix
             if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
@@ -44,6 +54,7 @@ class ZipDownloader extends ArchiveDownloader
                 }
 
                 $error = "Could not decompress the archive, enable the PHP zip extension or install unzip.\n".
+                    $iniMessage . "\n" .
                     'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
             }