How to disable XDebug
PhpXdebugApcPhp Problem Overview
I think that my server became slow since I installed XDebug. So, in order to test my hypothesis I want to disable XDebug completely. I've been searching for tutorials on how to do this but I can't find such information.
Php Solutions
Solution 1 - Php
Find your php.ini
and look for XDebug.
Set xdebug autostart to false
xdebug.remote_autostart=0
xdebug.remote_enable=0
Disable your profiler
xdebug.profiler_enable=0
Note that there can be a performance loss even with xdebug disabled but loaded. To disable loading of the extension itself, you need to comment it in your php.ini. Find an entry looking like this:
zend_extension = "/path/to/php_xdebug.dll"
and put a ;
to comment it, e.g. ;zend_extension = …
.
Check out this post https://stackoverflow.com/questions/2570680/xdebug-how-to-disable-remote-debugging-for-single-php-file
Solution 2 - Php
An easy solution working on Linux distributions similar to Ubuntu
sudo php5dismod xdebug
sudo service apache2 restart
Solution 3 - Php
In Linux Ubuntu(maybe also another - it's not tested) distribution with PHP 5 on board, you can use:
sudo php5dismod xdebug
And with PHP 7
sudo phpdismod xdebug
And after that, please restart the server:
sudo service apache2 restart
Solution 4 - Php
Also, you can add xdebug_disable()
to your code. Try:
if(function_exists('xdebug_disable')) { xdebug_disable(); }
Solution 5 - Php
I renamed the config file and restarted server:
$ mv /etc/php/7.0/fpm/conf.d/20-xdebug.ini /etc/php/7.0/fpm/conf.d/20-xdebug.ini.bak
$ sudo service php7.0-fpm restart && sudo service nginx restart
It did work for me.
Solution 6 - Php
Comment extension in php.ini and restart Apache. Here is a simple script (you can assign shortcut to it)
xdebug-toggle.php
define('PATH_TO_PHP_INI', 'c:/xampp/php/php.ini');
define('PATH_TO_HTTPD', 'c:/xampp/apache/bin/httpd.exe');
define('REXP_EXTENSION', '(zend_extension\s*=.*?php_xdebug)');
$s = file_get_contents(PATH_TO_PHP_INI);
$replaced = preg_replace('/;' . REXP_EXTENSION . '/', '$1', $s);
$isOn = $replaced != $s;
if (!$isOn) {
$replaced = preg_replace('/' . REXP_EXTENSION . '/', ';$1', $s);
}
echo 'xdebug is ' . ($isOn ? 'ON' : 'OFF') . " now. Restarting apache...\n\n";
file_put_contents(PATH_TO_PHP_INI, $replaced);
passthru(PATH_TO_HTTPD . ' -k restart');
Solution 7 - Php
in xubuntu I totally disabled xdebug for the CLI with this...
sudo rm /etc/php5/cli/conf.d/*xdebug*
Solution 8 - Php
On Windows (WAMP) in CLI ini file:
X:\wamp\bin\php\php5.x.xx\php.ini
comment line
; XDEBUG Extension
;zend_extension = "X:/wamp/bin/php/php5.x.xx/zend_ext/php_xdebug-xxxxxx.dll"
Apache will process xdebug
, and composer will not.
Solution 9 - Php
If you are using php-fpm
the following should be sufficient:
sudo phpdismod xdebug
sudo service php-fpm restart
Notice, that you will need to tweak this depending on your php version. For instance running php 7.0 you would do:
sudo phpdismod xdebug
sudo service php7.0-fpm restart
Since, you are running php-fpm there should be no need to restart the actual webserver. In any case if you don't use fpm then you could simply restart your webserver using any of the below commands:
sudo service apache2 restart
sudo apache2ctl restart
Solution 10 - Php
Two options:
1: Add following code in the initialization Script:
if (function_exists('xdebug_disable')) {
xdebug_disable();
}
2: Add following flag to php.ini
xdebug.remote_autostart=0
xdebug.remote_enable=0
1st option is recommended.
Solution 11 - Php
Find your PHP.ini and look for XDebug.
normally in Ubuntu its path is
/etc/php5/apache2/php.ini
Make following changes (Better to just comment them by adding ; at the beginning )
xdebug.remote_autostart=0
xdebug.remote_enable=0
xdebug.profiler_enable=0
then restart your server again for Ubuntu
sudo service apache2 restart
Solution 12 - Php
Disable xdebug
For PHP 7: sudo nano /etc/php/7.0/cli/conf.d/20-xdebug.ini
For PHP 5: sudo nano /etc/php5/cli/conf.d/20-xdebug.ini
Then comment out everything and save.
UPDATE -- Disable for CLI only
As per @igoemon's comment, this is a better method:
PHP 7.0 (NGINX)
sudo mv /etc/php/7.0/cli/conf.d/20-xdebug.ini /etc/php/7.0/cli/conf.d/20-xdebug.ini.old
sudo service nginx restart
Note: Update the path to your version of PHP.
Solution 13 - Php
#Ubuntu 16.04 remove xdebug from PHP.
###Find your php.ini file and make sure xdebug is there:
grep -r "xdebug" /etc/php/
This might come up with different versions, if so run php -v
to find your version.
###Edit the php.ini file, like:
sudo vi /etc/php/5.6/mods-available/xdebug.ini
###Comment the line:
//zend_extension=xdebug.so
###Save the file
Solution 14 - Php
Inspired by PHPStorm right click on a file -> debug -> ...
www-data@3bd1617787db:~/symfony$
php
-dxdebug.remote_enable=0
-dxdebug.remote_autostart=0
-dxdebug.default_enable=0
-dxdebug.profiler_enable=0
test.php
the important stuff is -dxdebug.remote_enable=0 -dxdebug.default_enable=0
Solution 15 - Php
I ran into a similar issue. Sometimes, you wont find xdebug.so in php.ini. In which case, execute phpinfo()
in a php file and check for Additional .ini files parsed
. Here you'll see more ini files. One of these will be xdebug's ini file. Just remove (or rename) this file, restart apache, and this extension will be removed.
Solution 16 - Php
I had following Problem: Even if I set
xdebug.remote_enable=0
Xdebug-Error-Message-Decoration was shown.
My solution:
xdebug.default_enable=0
Only if I use this Flag, Xdebug was disabled.
Solution 17 - Php
(This is for CentOS)
Rename the config file and restart apache.
sudo mv /etc/php.d/xdebug.ini /etc/php.d/xdebug.ini.old
sudo service httpd restart
Do the reverse to re-enable.
Solution 18 - Php
I created this bash script for toggling xdebug. I think it should work at least on Ubuntu / Debian. This is for PHP7+. For PHP5 use php5dismod / php5enmod.
#!/bin/bash
#
# Toggles xdebug
#
if [ ! -z $(php -m | grep "xdebug") ] ; then
phpdismod xdebug
echo "xdebug is now disabled"
else
phpenmod xdebug
echo "xdebug is now enabled"
fi
# exit success
exit 0
Solution 19 - Php
Disable xdebug only for certain PHP version or sapi. On this case PHP 7.2 fpm
sudo phpdismod -v 7.2 -s fpm xdebug
sudo service php7.2-fpm nginx restart
Solution 20 - Php
If you are using MAMP Pro on Mac OS X it's done via the MAMP client by unchecking Activate Xdebug under the PHP tab:
Solution 21 - Php
So, yeah, all what you need, just comment line in INI file like zend_extension=xdebug.so
or similar.
Comments can be made by adding semicolon.
But, such kind of answer already added, and I'd like to share ready solution to switch Xdebug status.
I've made quick switcher for Xdebug. Maybe it would be useful for someone.
Solution 22 - Php
For WAMP, click left click on the Wamp icon in the taskbar tray. Hover over PHP and then click on php.ini and open it in your texteditor.
Now, search for the phrase 'zend_extension' and add ; (semicolon) in front it.
Restart the WAMP and you are good to go.
Solution 23 - Php
Apache/2.4.33 (Win64) PHP/7.2.4 myHomeBrew stack
At end of php.ini I use the following to manage Xdebug for use with PhpStorm
; jch ~ Sweet analizer at https://xdebug.org/wizard.php for matching xdebug to php version.
; jch ~ When upgrading php versions check if newer xdebug.dll is needed in ext directory.
; jch Renamed... zend_extension = E:\x64Stack\PHP\php7.2.4\ext\php_xdebug-2.6.0-7.2-vc15-x86_64.dll
zend_extension = E:\x64Stack\PHP\php7.2.4\ext\php_xdebug.dll
; jch !!!! Added the following for Xdebug with PhpStorm
[Xdebug]
; zend_extension=<full_path_to_xdebug_extension>
; xdebug.remote_host=<the host where PhpStorm is running (e.g. localhost)>
; xdebug.remote_port=<the port to which Xdebug tries to connect on the host where PhpStorm is running (default 9000)>
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_output_dir="E:\x64Stack\Xdebug_profiler_output"
xdebug.idekey=PHPSTORM
xdebug.remote_autostart=1
; jch ~~~~~~~~~To turn Xdebug off(disable) uncomment the following 3 lines restart Apache~~~~~~~~~
;xdebug.remote_autostart=0
;xdebug.remote_enable=0
;xdebug.profiler_enable=0
; !!! Might get a little more speed by also commenting out this line above...
;;; zend_extension = E:\x64Stack\PHP\php7.2.4\ext\php_xdebug.dll
; so that Xdebug is both disabled AND not loaded
Solution 24 - Php
You can disable Xdebug on PHP CLI on runtime using the -d
flag:
php -d xdebug.mode=off -i | grep xdebug.mode
Result: xdebug.mode => off => off
Example, running unit tests with Xdebug disabled, so it's faster:
php -d xdebug.mode=off ./vendor/bin/phpunit
You can also create an alias for it to make it easier to use.
Solution 25 - Php
For those interested in disabling it in codeship, run this script before running tests:
rm -f /home/rof/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
I was receiving this error:
Use of undefined constant XDEBUG_CC_UNUSED - assumed 'XDEBUG_CC_UNUSED' (this will throw an Error in a future version of PHP)
which is now gone!
Solution 26 - Php
Since xdebug 3 came out the settings in pnp.ini
have slightly changed.
Setting:
xdebug.mode=off
Will disable all processing According to the docs:
> Nothing is enabled. Xdebug does no work besides checking whether > functionality is enabled. Use this setting if you want close to 0 > overhead.