php -i
在 php.ini 的最后加上以下内容
[Xdebug]
; xdebug 拓展的 so 或 dll 的路径,这里最好填绝对路径
zend_extension = path/to/xdebug
; 日志路径
; xdebug.remote_log = ""
; 跟踪输出路径
; xdebug.trace_output_dir = ""
; 是否开启远程调试
xdebug.remote_enable = on
; 是否开启分析器
; xdebug.profiler_enable = on
; 分析器文件路径
; profiler_output_dir = ""
; 允许调试的客户端IP
xdebug.remote_host = 127.0.0.1
; 远程调试的端口
xdebug.remote_port = 9003
; 开启远程调试自动启动
; xdebug.remote_autostart = on
; 显示局部变量
xdebug.show_local_vars = on
; 显示默认的错误信息
xdebug.default_enable = on
; ide key
xdebug.idekey = "vscode"
[Xdebug]
zend_extension = path/to/xdebug
xdebug.mode = "debug"
xdebug.idekey = "vscode"
xdebug.client_host = 127.0.0.1
xdebug.client_port = 9003
xdebug.connect_timeout_ms = 2000
在 VSCode 的拓展里搜索对应的插件名然后选择安装即可。
IntelliSense 的插件有两个, IntelliSense 只需要装一个就可以的了,笔者更喜欢用 PHP Intelephense 。
如果配置启用了自动调试,那么脚本的运行命令就不需要额外的参数, 浏览器也不需要 Xdebug Helper 插件。 但是这样会所有请求都启用调试。
php -d xdebug.remote_autostart=on test.php
php -d xdebug.start_with_request=on test.php
xdebug.idekey = "vscode"
XDEBUG_SESSION=vscode
), php 检测到 xdebug.idekey 后就会通知 IDE 启动调试XDEBUG_SESSION=vscode
,就是触发调试的了,类似于这样
curl -k --cookie "XDEBUG_SESSION=vscode" http://testurl
https://sourceforge.net/projects/qcachegrindwin/
xdebug.profiler_enable = on
xdebug.profiler_output_dir = ""
https://github.com/jokkedk/webgrind