Disabling xdebug when running composer

前端 未结 18 1214
北海茫月
北海茫月 2021-01-29 21:18

When running composer diagnose, I get the following error :

The xdebug extension is loaded, this can slow down Composer a little. Disablin

18条回答
  •  天涯浪人
    2021-01-29 21:20

    I usually create a shell script per project, since every project has another PHP version. It's in a /bin/ directory next to composer.phar and composer.json and I run it as ./bin/composer in my project directory.

    It looks like this (for php56)

    #!/bin/sh
    DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    
    COMPOSER_DISABLE_XDEBUG_WARN=1 /opt/local/bin/php56 \
        -d xdebug.remote_enable=0 -d xdebug.profiler_enable=0 \
        -d xdebug.default_enable=0 $DIR/../composer.phar "$@"
    

    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

    Run without xdebug: 0m10

提交回复
热议问题