Jelajahi Sumber

Merge pull request #4615 from staabm/xdebugwarn

add a warning when xdebug is loaded while running composer commands
Jordi Boggiano 9 tahun lalu
induk
melakukan
4071b09091
2 mengubah file dengan 21 tambahan dan 0 penghapusan
  1. 17 0
      doc/articles/troubleshooting.md
  2. 4 0
      src/Composer/Console/Application.php

+ 17 - 0
doc/articles/troubleshooting.md

@@ -131,6 +131,23 @@ Or, you can increase the limit with a command-line argument:
 php -d memory_limit=-1 composer.phar <...>
 ```
 
+## Xdebug impact on Composer
+
+Running Composer console commands while the php extension "xdebug" is loaded reduces speed considerably.
+This is even the case when all "xdebug" related features are disabled per php.ini flags,
+but the php extension itself is loaded into the PHP engine.
+Compared to a cli command run with "xdebug" enabled a speed improvement by a factor of up to 3 is not uncommon.
+
+> **Note:** This is a general issue when running PHP with "xdebug" enabled. You shouldn't
+> load the extension in production like environments per se.
+
+Disable "xdebug" in your `php.ini` (ex. `/etc/php5/cli/php.ini` for Debian-like systems) by
+locating the related `zend_extension` directive and prepending it with `;` (semicolon):
+
+```sh
+;zend_extension = "/path/to/my/xdebug.so"
+```
+
 ## "The system cannot find the path specified" (Windows)
 
 1. Open regedit.

+ 4 - 0
src/Composer/Console/Application.php

@@ -110,6 +110,10 @@ class Application extends BaseApplication
         if (PHP_VERSION_ID < 50302) {
             $io->writeError('<warning>Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.</warning>');
         }
+        
+        if (extension_loaded('xdebug')) {
+            $io->write('<warning>You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug</warning>');
+        }        
 
         if (defined('COMPOSER_DEV_WARNING_TIME')) {
             $commandName = '';