Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何禁用XDebug_Php_Xdebug_Apc - Fatal编程技术网

Php 如何禁用XDebug

Php 如何禁用XDebug,php,xdebug,apc,Php,Xdebug,Apc,我认为自从我安装了XDebug之后,我的服务器速度变慢了。 所以,为了检验我的假设,我想完全禁用XDebug。 我一直在搜索有关如何执行此操作的教程,但找不到此类信息。找到您的php.ini并查找XDebug 将xdebug autostart设置为false xdebug.remote_autostart=0 xdebug.remote_enable=0 禁用您的探查器 xdebug.profiler_enable=0 请注意,可能存在一个错误。要禁用扩展本身的加载,需要在php.in

我认为自从我安装了XDebug之后,我的服务器速度变慢了。 所以,为了检验我的假设,我想完全禁用XDebug。
我一直在搜索有关如何执行此操作的教程,但找不到此类信息。

找到您的
php.ini
并查找XDebug

将xdebug autostart设置为false

xdebug.remote_autostart=0  
xdebug.remote_enable=0
禁用您的探查器

xdebug.profiler_enable=0
请注意,可能存在一个错误。要禁用扩展本身的加载,需要在php.ini中对其进行注释。查找如下所示的条目:

zend_extension = "/path/to/php_xdebug.dll"
并放置一个
对其进行注释,例如
;zend_扩展=…


查看此帖子

此外,您还可以在代码中添加
xdebug\u disable()
。尝试:


如果(函数_存在('xdebug_disable')){xdebug_disable();}

在php.ini中注释扩展,然后重新启动Apache。这是一个简单的脚本(您可以为其指定快捷方式)

xdebug-toggle.php

两种选择:

1:在初始化脚本中添加以下代码:

 if (function_exists('xdebug_disable')) {
           xdebug_disable();
         }
2:将以下标志添加到php.ini

 xdebug.remote_autostart=0
 xdebug.remote_enable=0

建议使用第一个选项。

在xubuntu中,我使用此选项完全禁用了CLI的xdebug

sudo rm /etc/php5/cli/conf.d/*xdebug*

我遇到了类似的问题。有时候,在php.ini中找不到xdebug.so。在这种情况下,在php文件中执行
phpinfo()
,并检查是否解析了
其他.ini文件。在这里,您将看到更多ini文件。其中之一就是xdebug的ini文件。只要删除(或重命名)这个文件,重新启动apache,这个扩展就会被删除。

一个简单的解决方案,可以在类似于Ubuntu的Linux发行版上工作

sudo php5dismod xdebug
sudo service apache2 restart
我有以下问题: 即使我设定

xdebug.remote_enable=0 
显示了Xdebug错误消息

我的解决方案:

xdebug.default_enable=0
仅当我使用此标志时,Xdebug才被禁用。

在CLI ini文件中的Windows(WAMP)上:

X:\wamp\bin\php\php5.X.xx\php.ini

评论行

; XDEBUG Extension

;zend_extension = "X:/wamp/bin/php/php5.x.xx/zend_ext/php_xdebug-xxxxxx.dll"

Apache将处理
xdebug
,而composer不会处理。

如果您在Mac OS X上使用MAMP Pro,则通过MAMP客户端取消选中PHP选项卡下的Activate xdebug来完成:


我重命名了配置文件并重新启动了服务器:

$ 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
它确实对我有用。

(这是给CentOS的)

重命名配置文件并重新启动apache

sudo mv /etc/php.d/xdebug.ini /etc/php.d/xdebug.ini.old
sudo service httpd restart

执行相反的操作以重新启用。

找到您的PHP.ini并查找XDebug

通常在Ubuntu中,它的路径是

/etc/php5/apache2/php.ini  
进行以下更改(最好在开头添加注释)

然后重新启动服务器 Ubuntu也是如此

sudo service apache2 restart

禁用xdebug

对于PHP7:
sudo nano/etc/PHP/7.0/cli/conf.d/20 xdebug.ini

对于php5:
sudo nano/etc/php5/cli/conf.d/20 xdebug.ini

然后注释掉所有内容并保存


更新--仅对CLI禁用

根据@igoemon的评论,这是一种更好的方法:

PHP7.0(NGINX)


注意:更新PHP版本的路径。

Linux Ubuntu(也可能是另一个-未经测试)发行版中,使用PHP 5,您可以使用:

sudo php5dismod xdebug
并使用PHP7

sudo phpdismod xdebug
然后,请重新启动服务器:

sudo service apache2 restart

所以,是的,所有你们需要的,只是INI文件中的注释行,比如
zend_extension=xdebug.So
或者类似的

可以通过添加分号进行注释

但是,已经添加了这样的答案,我想与大家分享切换Xdebug状态的现成解决方案

我为Xdebug制作了快速切换程序。也许这对某人有用


对于WAMP,单击任务栏托盘中的WAMP图标。将鼠标悬停在PHP上,然后单击PHP.ini并在文本编辑器中打开它

现在,搜索短语“zend_extension”并添加;(分号)在它前面

重新启动WAMP,就可以开始了。

Ubuntu 16.04从PHP中删除xdebug。 找到php.ini文件并确保xdebug在那里: 这可能会产生不同的版本,如果是这样,请运行
php-v
来查找您的版本

编辑php.ini文件,如: 评论该行:
保存文件如果您使用的是
php fpm
,则以下内容应足够:

sudo phpdismod xdebug
sudo service php-fpm restart
请注意,您需要根据您的php版本对此进行调整。例如,运行php 7.0时,您将执行以下操作:

sudo phpdismod xdebug
sudo service php7.0-fpm restart
因为您正在运行php fpm,所以不需要重新启动实际的Web服务器。在任何情况下,如果不使用fpm,则可以使用以下任何命令简单地重新启动Web服务器:

sudo service apache2 restart
sudo apache2ctl restart
Apache/2.4.33(Win64)PHP/7.2.4 myHomeBrew堆栈

在php.ini的末尾,我使用以下内容来管理Xdebug,以便与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
;jch~甜味安乃近https://xdebug.org/wizard.php 用于将xdebug与php版本匹配。
; jch~升级php版本时,请检查ext目录中是否需要更新的xdebug.dll。
; jch更名为。。。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!!!!为带有PhpStorm的Xdebug添加了以下内容
[Xdebug]
; zend_扩展=
; xdebug.remote\u主机=
; xdebug.remote\u端口=
xdebug.remote\u enable=1
xdebug.remote\u host=localhost
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler\u output\u dir=“E:\x64Stack\xdebug\u profiler\u output”
xdebug.idekey=PHPSTORM
xdebug.remote\u autostart=1
; jch~~~~~~~~~~~~要关闭(禁用)Xdebug,请取消注释以下3行内容,重新启动Apache~~~~~~~~
;xdebug.remote\u autostart=0
;xdebug.remote\u enable=0
;xdebug.profiler_enable=0
; !!! 可能会得到一个多一点的速度也评论了这一行以上。。。
;;; zend_extension=E:\x64Stack\PHP\php7.2.4\ext\PHP_xdebug.dll
; 这样Xdebug既被禁用,又没有加载

受PHPStorm启发,右键单击文件->调试->

www-data@3bd1617787db:~/symfony$ 
php 
-dxdebug.remote_enable=0 
-dxdebug.remote_autostart=0 
-dxdebug.default_enable=0 
-dxdebug.profiler_enable=0 
test.php

重要的是
-dxdebug.remote\u enable=0-dxdebug.default\u enable=0

我创建了这个bash脚本来切换xdebug。我认为它至少应该在Ubuntu/Debian上运行。这是针对PHP7+的。对于PHP5,使用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

sudo phpdismod xdebug sudo service php-fpm restart

sudo phpdismod xdebug
sudo service php7.0-fpm restart
sudo service apache2 restart
sudo apache2ctl restart
; 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
www-data@3bd1617787db:~/symfony$ 
php 
-dxdebug.remote_enable=0 
-dxdebug.remote_autostart=0 
-dxdebug.default_enable=0 
-dxdebug.profiler_enable=0 
test.php
#!/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
rm -f /home/rof/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
Use of undefined constant XDEBUG_CC_UNUSED - assumed 'XDEBUG_CC_UNUSED' (this will throw an Error in a future version of PHP)