Reputation: 7752
I'm having trouble disabling xDebug. I've commented out the zend_extension from the configuration file as suggested here
/etc/php/7.0/apache2/conf.d/20-xdebug.ini
zend_extension=xdebug.so
;zend_extension=/usr/lib/xdebug/modules/xdebug.so
xdebug.max_nesting_level=200
xdebug.remote_enable=1
xdebug.remote_host=192.168.10.1
xdebug.idekey=phpstorm
After restarting Apache2, I still get the following error message when I run composer.
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
I found another xdebug.ini file and it's also seems to be disabled there:
cat /etc/php/7.0/mods-available/xdebug.ini
zend_extension=xdebug.so
;zend_extension=/usr/lib/xdebug/modules/xdebug.so
xdebug.max_nesting_level=200
xdebug.remote_enable=1
xdebug.remote_host=192.168.10.1
xdebug.idekey=phpstorm
Do I need to restart PHP, how do I do that?
$ sudo service php restart
php: unrecognized service
Upvotes: 0
Views: 2095
Reputation: 311
IF you are - like me - working in a dev-VM, where you are always root, you can add the following code to your .bashrc to temporarily disable XDebug when running composer:
# Composer WITHOUT XDebug
composer(){
xdbEnabled=$(php -r 'echo extension_loaded('xdebug');')
hasBeenDisabled='0' # not needed, just for clarification and better readability
if [ $xdbEnabled == '1' ]
then
echo 'XDebug is enabled. Disabling temporarily.'
phpdismod xdebug
hasBeenDisabled='1'
fi
php /path/to/composer.phar "$@" # or just 'composer "$@"', if it is installed globally
if [ $hasBeenDisabled == '1' ]
then
phpenmod xdebug
echo 'XDebug has been reenabled.'
fi
}
If you are not root, you would have to call it with sudo composer [args]
, since phpdismod
and phpenmod
require root.
However, you should not do that on your host system or any other environment that is not easily recoverable and sandboxed, since running composer as root is potentially dangerous (Packages can register scripts that run on install and/or update, and you can't trust every package you require).
EDIT:
This works for PHP >= 7. For PHP 5, replace phpdismod
and phpenmod
with php5dismod
and php5enmod
(not tested).
2nd Edit: AFAIK, phpenmod
and phpdismod
are only available on Ubuntu/Debian based systems.
Upvotes: 0
Reputation: 863
You can find same answer here... disabling-xdebug-when-running-composer
Upvotes: 0