第一步:VS Code 安装 php debug 扩展
打开 VS Code
Ctrl + Shift + X, 调出 VS Code 扩展搜索窗口
在搜索窗口搜索 PHP Debug,点击 'install' 按钮,安装
(我的已经装过了,所以没有安装按钮了)
中标题
第二步,配置 VS Code 的 Debug
1. 设置中添加 “php.validate.executablePath” 项
在搜索栏里搜索 php.validate.executablePath
在 setting.json 文件里,加上 php.validate.executablePath
2. 配置 debug 的 config
打开调试面板,点击小齿轮,打开 launch.json 文件
如果没有 launch.json 文件,则需要自己手动创建:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
第三步:PHP 安装 debug 扩展
- 然后在随便一个页面输出一下phpinfo();
- Ctrl+A 复制页面的内容到 https://xdebug.org/wizard.php 的文本框内
- 点击下面的 Analyse my phpinfo() output 按钮获取对应的xdebug.dll文件
- 将 xdebug.dll 下载下来放到当前版本php目录下的zend_ext文件夹内
- 编辑 php.ini, 加上 xdebug 的配置
[XDebug]
zend_extension = "D:/wamp/bin/php/php7.2.14/zend_ext/php_xdebug-2.6.1-7.2-vc15-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.romote_host=localhost
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.remote_port=9003//关键在于这个端口号要和launch.json配置的端口号对应起来。
**然后重启服务器就ok啦~~
总之我是这么配起来哒,仅供参考~~**
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。