PHPStorm 2026.2 配置 Xdebug 调试详细教程
发布时间:2026年8月15日10:25:47
Xdebug 插件的安装过程此处省略,用户可自行搜索相关安装指南,Windows 与 Linux 环境下的安装步骤存在差异。
务必注意 Xdebug 版本需与当前 PHP 版本保持兼容。
1、查看 phpinfo 信息

2、修改 php.ini 配置文件
[xdebug]
zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.remote_enable =1
xdebug.profiler_enable = On
xdebug.auto_trace=On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.remote_handler ="dbgp"
xdebug.remote_host ="172.16.6.44"
xdebug.remote_mode ="req"
xdebug.remote_port =9000
xdebug.idekey = "PHPSTORM"
xdebug.remote_autostart = 1
;xdebug.remote_connect_back = 1
; If openssl.cafile is not specified or if the CA file is not found, the
; directory pointed to by openssl.capath is searched for a suitable
; certificate. This value must be a correctly hashed certificate directory.
; Most users should not specify a value for this directive as PHP will
; attempt to use the OS-managed cert stores in its absence. If specified,
; this value may still be overridden on a per-stream basis via the "capath"
; SSL stream context option.
;openssl.capath=
; Local Variables:
; tab-width: 4
; End:
xdebug.var_display_max_children=10240
xdebug.var_display_max_data=10240
xdebug.var_display_max_depth=10240
3、确保已正确安装 xdebug.so 扩展文件。

4、对编辑器 PHPStorm 进行相应配置

进入 Settings 设置界面

调试端口需与 php.ini 中的配置保持一致

配置本机 IP 地址,若使用虚拟机则 IP 为 192.168.99.26


查看输出窗口的调试信息

在代码界面观察输出结果


1. 首先检查 PHPStorm 的 Xdebug 配置项
-> 此处的 debug port 必须与 php.ini 内的 xdebug.remote_port 一致!默认值为 9000,若该端口被占用,可更改为其他可用端口。
4. 开始使用断点进行调试
-> 开启调试模式(在 PHPStorm 中操作)
1、在代码行号旁设置断点

按 F9 跳出当前断点
按 F8 执行下一步
-> 在浏览器中添加开启和关闭调试的按钮
https://www.jetbrains.com/phpstorm/marklets/

-> 在代码中打断点后,运行访问该页面的 URL
在浏览器中开启调试功能,然后刷新页面即可生效。
总结
至此,关于 PHP 开发中最强大的 IDE 编辑工具 PHPStorm 2026.2 配置 Xdebug 调试的详细教程已介绍完毕,更多相关 PHPStorm 调试配置 Xdebug 内容请搜索本站以前的文章或继续浏览下面的相关文章希望大家以后多多支持本站!