# 必备条件
- VSCode 扩展 PHP Debug
- VSCode 扩展 Code Runner
# 开始调试
-
基本配置
- https://segmentfault.com/a/1190000019475551
-
xdebug调试原理-配置xdebug参数
- https://www.xiebruce.top/1715.html
- https://blog.chaosjohn.com/Debug-php-continued.html
-
排查故障
- 编辑好test.php后,使用扩展 Code Runner 运行php文件,确认运行正常且能进入debug;
- 配置 VSCode
launch.json
{ // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Listen for XDebug", "type": "php", "request": "launch", "log": true, "port": 9003, }, { "name": "Launch currently open script", "type": "php", "request": "launch", "program": "${file}", "cwd": "${fileDirname}", "log": true, "port": 9000, } ] }
- 集成环境新建php服务,该服务端口需要匹配
launch.json
中"Launch currently open script"
的配置端口(即:9000) - 网页访问
127.0.0.1:9000/test.php
(127.0.0.1|localhost) - 成功