When running composer diagnose
, I get the following error :
The xdebug extension is loaded, this can slow down Composer a little. Disablin
This command will disable the PHP5 Xdebug module for CLI (and thus composer) :
sudo php5dismod -s cli xdebug
It removes the xdebug.ini symlink from /etc/php5/cli/conf.d/
This was suggested on http://blog.lorenzbausch.de/2015/02/10/php-disable-xdebug-for-cli/
Note that for Ubuntu 16.04 you probably need to run it like this:
sudo phpdismod -s cli xdebug
(Windows)
Based on documentation I use environment variable PHPRC
, so I can choose which INI file shloud be loaded, thus I can choose whether I want to enable or disable Xdebug before executing a command (like composer install
).
I have two INI files, one with Xdebug enabled (php-xdebug.ini
) and one with Xdebug disabled (php.ini
- it's also default one).
I use some batches (placed in location which is included in PATH
environment variable, so it can be executed from anywhere):
To enable Xdebug I call xon.bat
:
@ECHO OFF
set PHPRC=C:/path-to-php/php-xdebug.ini
To disable Xdebug I call xoff.bat
:
@ECHO OFF
set PHPRC=
By calling php --ini
I can check which INI file was loaded.
Alternatively you can use environment variable PHP_INI_SCAN_DIR
in which you set a path to directory from where additional INI files will be loaded. Advantage is that you can load multiple INI files.
If you install composer using brew on OS X You can use this alias:
alias composer="php -n $(cat $(which composer) | grep composer.phar | awk '{print $7}')"
Creating an alias for composer to disable xdebug and prevent memory errors:
Add this line to your ~/.bash_profile
alias composer='php -d xdebug.profiler_enable=0 -d memory_limit=-1 /usr/local/bin/composer'
Restart the terminal to make the new alias available.
Here is my quick solution to get rid off the Xdebug warning on PHP5-cli version. I have removed the support of Xdebug for PHP5-cli on Ubuntu 14.04.
cd /etc/php5/cli/conf.d/
sudo rm 20-xdebug.ini
Now no more Xdebug warning on PHP5-cli.
Update: For Xdebug 3+:
As of Xdebug 3, it is possible to disable the Xdebug completely by setting the option xdebug.mode
to off
, or by setting the environment variable XDEBUG_MODE=off
.
It is very easy to disable Xdebug just for composer, by aliasing composer
.
alias composer='XDEBUG_MODE=off \composer'
OR
alias composer='php -dxdebug.mode=off $(where composer | fgrep -v composer: | head -1)'
You can add the alias to your $HOME/.bashrc
to make it permanent.
Update: For Xdebug 1.3 - 3.0.0 :
The issue has been fixed in Composer 1.3. Update composer to the latest version by executing composer self-update
, instead of trying the following workaround.
For Xdebug < 1.3
Here is my modification of @ezzatron's code. I have updated the script to detect ini files from phpinfo output.
#!/bin/sh
php_no_xdebug () {
temporaryPath="$(mktemp -t php.XXXX).ini"
# Using awk to ensure that files ending without newlines do not lead to configuration error
php -i | grep "\.ini" | grep -o -e '\(/[a-z0-9._-]\+\)\+\.ini' | grep -v xdebug | xargs awk 'FNR==1{print ""}1' | grep -v xdebug > "$temporaryPath"
php -n -c "$temporaryPath" "$@"
rm -f "$temporaryPath"
}
php_no_xdebug /usr/local/bin/composer.phar $@
# On MacOS with composer installed using brew, comment previous line
# Install jq by executing `brew install jq` and uncomment following line.
# php_no_xdebug /usr/local/Cellar/composer/`brew info --json=v1 composer | jq -r '.[0].installed[0].version'`/libexec/composer.phar $@