php 如何禁用 XDebug
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8754826/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable XDebug
提问by Beto Aveiga
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.
我认为自从我安装 XDebug 以来,我的服务器变慢了。因此,为了测试我的假设,我想完全禁用 XDebug。我一直在寻找有关如何执行此操作的教程,但找不到此类信息。
回答by Uday Sawant
Find your php.ini
and look for XDebug.
找到您的php.ini
并寻找 XDebug。
Set xdebug autostart to false
将 xdebug 自动启动设置为 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:
请注意,即使禁用 xdebug 但已加载,也可能会导致性能损失。要禁用扩展本身的加载,您需要在 php.ini 中对其进行注释。找到一个看起来像这样的条目:
zend_extension = "/path/to/php_xdebug.dll"
and put a ;
to comment it, e.g. ;zend_extension = …
.
并把 a;
评论它,例如;zend_extension = …
。
Check out this post XDebug, how to disable remote debugging for single .php file?
回答by Arvi V?ime
An easy solution working on Linux distributions similar to Ubuntu
在类似于 Ubuntu 的 Linux 发行版上工作的简单解决方案
sudo php5dismod xdebug
sudo service apache2 restart
回答by kkochanski
In Linux Ubuntu(maybe also another - it's not tested) distribution with PHP 5on board, you can use:
在带有PHP 5 的Linux Ubuntu(也许也是另一个 - 未经测试)发行版中,您可以使用:
sudo php5dismod xdebug
And with PHP 7
和PHP 7
sudo phpdismod xdebug
And after that, please restart the server:
之后,请重新启动服务器:
sudo service apache2 restart
回答by Zack Katz
Also, you can add xdebug_disable()
to your code. Try:
此外,您可以添加xdebug_disable()
到您的代码中。尝试:
if(function_exists('xdebug_disable')) { xdebug_disable(); }
if(function_exists('xdebug_disable')) { xdebug_disable(); }
回答by Sinan Eldem
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.
它确实对我有用。
回答by antonpinchuk
Comment extension in php.ini and restart Apache. Here is a simple script (you can assign shortcut to it)
在 php.ini 中注释扩展并重新启动 Apache。这是一个简单的脚本(您可以为其指定快捷方式)
xdebug-toggle.php
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 . '/', '', $s);
$isOn = $replaced != $s;
if (!$isOn) {
$replaced = preg_replace('/' . REXP_EXTENSION . '/', ';', $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');
回答by Artistan
in xubuntu I totally disabled xdebug for the CLI with this...
在 xubuntu 中,我完全禁用了 CLI 的 xdebug...
sudo rm /etc/php5/cli/conf.d/*xdebug*
回答by Vladimir Vukanac
On Windows (WAMP) in CLI ini file:
在 CLI ini 文件中的 Windows (WAMP) 上:
X:\wamp\bin\php\php5.x.xx\php.ini
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.
Apache 会处理xdebug
,而 composer 不会。
回答by Shadab Salam
Find your PHP.ini and look for XDebug.
找到您的 PHP.ini 并查找 XDebug。
normally in Ubuntu its path is
通常在 Ubuntu 中,它的路径是
/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
然后为 Ubuntu 再次重新启动您的服务器
sudo service apache2 restart
回答by Justin
Disable xdebug
禁用 xdebug
For PHP 7: sudo nano /etc/php/7.0/cli/conf.d/20-xdebug.ini
对于 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
对于 PHP 5: sudo nano /etc/php5/cli/conf.d/20-xdebug.ini
Then comment out everything and save.
然后注释掉所有内容并保存。
UPDATE -- Disable for CLI only
更新 - 仅对 CLI 禁用
As per @igoemon's comment, this is a better method:
根据@igoemon 的评论,这是一个更好的方法:
PHP 7.0 (NGINX)
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.
注意:更新您的 PHP 版本的路径。