Disabling xdebug when running composer

disable xdebug
phpunit disable xdebug
disable xdebug by default
lando disable xdebug
turn xdebug
laravel valet disable xdebug
how to uninstall xdebug on ubuntu
phpdismod command not found

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?

Update : 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.

Here is my modification of @ezzatron's code. I have updated the script to detect ini files from phpinfo output.


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 $@

Disable xdebug for one run, This script disables xdebug for one run. No more error-messages like: $ composer update You are running composer with xdebug enabled. The -d options effectively disable xdebug. The COMPOSER_DISABLE_XDEBUG_WARN=1 part disables the warning composer issues. Disabling the xdebug extension is preferred (see composer troubleshooting), but I personally like the simpler script. Some timings on my machine: 2 Run with xdebug and ini-enabled: 1m33. Run with xdebug but ini-disabled: 0m19

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

Disable Xdebug when running Composer, Disable Xdebug when running Composer. Published on Mar 2016. If you have Xdebug enabled when running CLI applications but do not want it to be loaded� So an awesome solution how to disable Xdebug running Composer on Trellis! The solution is to run the following command: sudo phpdismod -s cli xdebug This will disable Xdebug for CLI purposes.

I don’t think there is an option to configure PHP so it can load different configurations according to the targeted script. At least, not without duplicating .ini files...

However, you can add thoses options when running composer with php:

php -n -d extension=needed_ext.so composer.phar

-n will tell PHP to ignore any php.ini. This will prevent xdebug from loading for this very command.

-d options permits you to add any option you want (for exemple, activate needed_ext.so). You can use multiple -d options. Of course, this is optional, you might not need it.

Then you can create an alias, to make it sugary again.

A typical solution (because composer needs json):

php -n -d extension=json.so composer.phar

greg0ire > my solution, based on that:

options=$(ls -1 /usr/lib64/php/modules| \

    grep --invert-match xdebug| \

    # remove problematic extensions
    egrep --invert-match 'mysql|wddx|pgsql'| \

    sed --expression 's/\(.*\)/ --define extension=\1/'| \

    # join everything together back in one big line
    tr --delete '\n'

# build the final command line
php --no-php-ini $options ~/bin/composer $*

alias composer=/path/to/bash/script.sh

It looks ugly (I tried and failed to do that with xargs), but works… I had to disable some extensions though, otherwise I get the following warnings:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mysqli.so' - /usr/lib64/php/modules/mysqli.so: undefined symbol: mysqlnd_connect in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_mysql.so' - /usr/lib64/php/modules/pdo_mysql.so: undefined symbol: pdo_parse_params in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_pgsql.so' - /usr/lib64/php/modules/pdo_pgsql.so: undefined symbol: pdo_parse_params in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/wddx.so' - /usr/lib64/php/modules/wddx.so: undefined symbol: php_XML_SetUserData in Unknown on line 0

How To Disable Xdebug with PHP 7 CLI Ubuntu, If you are running PHP 7 with Xdebug, or like me, use Laravel Homestead, you might have seen this error message: You are running composer� diable xdebug temporary for Composer runs to avoid slow downs Notes: zend_extensions can not be disabled from the CLI, when invoking php.exe its also not possible to override this value by a .user.ini we need to modify the php.ini or pro

By creating an alias you'll suppress that composer xdebug error message.

Just add this line to your ~/.bash_aliases within your system and it should work flawlessly.

alias composer="php -n /usr/local/bin/composer"

Reload the shell to make the new alias composer available.

source ~/.bash_profile


$ composer --version

NOTE: You don't necessarily need to use any other parameter. Depending on your system you might have a .bashrc instead of .bash_profile.


As @AlexanderKachkaev mention in the comments it's worth nothing to add the memory_limit as follows to avoid crashing im some situations:

alias composer="php -d memory_limit=-1 -n /usr/local/bin/composer"

How can I disable the xdebug?, each time when I run composer update .. I get this message: You are running composer with xdebug enabled. This has a major impact on� I use a simple wrapper script that disables xdebug, runs composer, then reenables it. I only recommend this for non shared dev environments as php5dismod works by disabling symlinks to php.ini files. As far as I know, this is only supported on Debian distros. #!/bin/sh sudo php5dismod xdebug composer $@ sudo php5enmod xdebug

I came up with an answer that works pretty well for OSX, and could probably be adapted for any PHP version that loads its extensions using individual .ini files in the "additional ini dir":


function php-no-xdebug {
    local temporaryPath="$(mktemp -t php-no-debug)"

    find /opt/local/etc/$1/php.ini /opt/local/var/db/$1/*.ini ! -name xdebug.ini | xargs cat > "$temporaryPath"
    php -n -c "$temporaryPath" "${@:2}"
    rm -f "$temporaryPath"

alias composer="php-no-xdebug php56 ~/bin/composer"

PhpStorm + Composer, Hello, I installed composer in a Windows machine using the provided installer and it doesn't seem to disable xdebug properly. Whenever I run� This script disables xdebug for one run. No more error-messages like: $ composer update You are running composer with xdebug enabled. This has a major impact on runtime performance.

composer 1.7.3 doesn't disable xdebug on archlinux � Issue #7807 , I have installed xdebug php extension, composer is supposed to automatically disable xdebug when installed, but it's not the case with my� To improve performance when the Xdebug extension is enabled, Composer automatically restarts PHP without it. You can override this behavior by using an environment variable: COMPOSER_ALLOW_XDEBUG=1. Composer will always show a warning if Xdebug is being used, but you can override this with an environment variable: COMPOSER_DISABLE_XDEBUG_WARN=1.

How to turn off XDebug?, There's a sort of bonus message, "You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://� $ sudo phpdismod -s cli xdebug The -s flag tells it to disable Xdebug for the CLI SAPI ( /etc/php/7.0/cli ) and not FPM. And just like that, the warning message should be gone.

Disabling Xdebug on Mac's PHP CLI – Spencer Jones, Additionally, it's a lot slower to run composer with xdebug. Both good reasons to disable it. However, Composer's directions weren't so helpful� At this point, all you need to do is load php-no-xdebug.ini when you run composer or other operations you don’t want xdebug enabled for. Add or update an alias to composer in your bash_profile: alias composer="php -c /full/path/to/php-no-xdebug.ini /path/to/composer.phar" Don’t forget to source bash_profile once you’ve finished.

  • This is by far the most elegant solution to the problem, IMHO. Thanks Joyce!
  • Best. Script. Ever
  • I had to adjust the shebang to bin/bash rather than /bin/sh, as the latter did not like the function keyword (Ubuntu 14.04 LTS).
  • I have updated the code and removed the function keyword, for better compatibility.
  • You can confirm that you are running the latest version by running composer self-update
  • I've added the two aliases alias xdebug-on='sudo php5enmod -s cli xdebug' and alias xdebug-off='sudo php5dismod -s cli xdebug', so it's now easy to enable xdebug-on and disable xdebug-off xdebug.
  • Not portable. Probably Linux-only.
  • Works great on Laravel Homestead box (Ubuntu/Debian). A longer description of how it works: laracasts.com/discuss/channels/forge/disable-xdebug
  • thanks for this :) but I have ubuntu 16.04 and if someone will need to use this just run sudo phpdismod -s cli xdebug
  • How about php7 in ubuntu? Do I only need to remove the symlink ? /etc/php/7.0/cli/conf.d
  • I tried -n yesterday and had a problem because I was missing the phar extension. I'll try adding more and more extension until it works, I think this is a good solution. As per the alias, I have already some zsh aliases that I don't maintain. Maybe I'll try to replace the binary with a bash script, or see if I can configure the aliases.
  • The problem with this whitelist approach, though, is that the whitelist might grown depending on what people require in their composer.json, for instance "ext-ldap" : "*", or simply depending on what is needed to make the post install tasks run properly… If only there were a way to blacklist an extension…