When running composer diagnose
, I get the following error :
The xdebug extension is loaded, this can slow down Composer a little. Disabling it when using Composer is recommended.
How can I disable xdebug only when I'm running Composer?
XDebug works over the protocol that requires your local machine to listen for incoming connections from a server where an application you are debugging is located. You may already have used debugging tools that simply connect to a remote server or a process of your application.
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 $@
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With