PHP Windows 下 XAMPP 的 xdebug 配置

在 IntelliJ 下调试 PHP 的断点有时候还是比较困惑的。

同时根据你使用的 xdebug 配置也有关系。

xdebug 2.x

下面的配置是 xdebug Version 2 的配置,如果你使用 xdebug 3.x 版本的话,配置是不同的。

[XDebug]
zend_extension = "php_xdebug.dll"
xdebug.remote_autostart = 1
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "/xampp/tmp"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log = "/xampp/tmp/xdebug.txt"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "/xampp/tmp"
xdebug.remote_cookie_expire_time = 36000

xdebug 3.x

下面的配置是 xdebug 3.x 版本的配置,这个版本的配置已经有了不少的修改。

如果直接使用 xdebug 2.x 版本的配置的话,可能会遇到 IntelliJ 断点不停的问题。

[XDebug]
zend_extension = "xdebug"
xdebug.mode=debug
xdebug.client_host = 127.0.0.1
xdebug.client_port = "9003"
xdebug.start_with_request=yes

改变

从 xdebug 3.x 开始,默认的调试端口使用了 9003 的端口,这个与 xdebug 2.x 使用的 9000 端口是不一样的。

这个需要注意。

另外:xdebug.start_with_request=yes 参数必须要添加,否则 IntelliJ 的断点不停。

官方的这篇文章:Configure Xdebug | IntelliJ IDEA Documentation 非常值得参考,最好仔细阅读下。