Php 5.6.21 与 Xdebug 2.4 非常慢

Php 5.6.21 with Xdebug 2.4 is very slow

我已经在 Windows 7 x64 上安装了 XAMPP,在安装 xdebug 2.4 之后,一切都变慢了 (10X) 在 php.ini 我补充说:

[Xdebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.4.0rc4-5.6-vc11.dll"
xdebug.remote_enable = 0
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "C:\Tmp"
xdebug.remote_host = "localhost"

正如@terminus 已经指出的,您已将 xdebug.profiler_enable 设置为 true,这意味着每次执行 PHP 脚本时,您的探查器都会 运行。

摘自 xdebug docs

xdebug.profiler_enable
Type: integer, Default value: 0 Enables Xdebug's profiler which creates files in the profile output directory. Those files can be read by KCacheGrind to visualize your data. This setting can not be set in your script with ini_set(). If you want to selectively enable the profiler, please set xdebug.profiler_enable_trigger to 1 instead of using this setting.

解决主要问题 禁用 xdebug.profiler_enable启用 xdebug.profiler_enable_trigger

之后,您可以通过 HTTP 传递 XDEBUG_PROFILE 参数来 运行 探查器:

curl 'http://localhost/?XDEBUG_PROFILE=1'  

或者在命令行中使用 xdebug.profiler_enable 选项:

$ php -d xdebug.profiler_enable=On <yourphpscrip>.php

请注意:使用 X-Debug 总是会减慢脚本的执行时间,因此切勿在生产环境中安装 X-Debug。