php+vscode+nginx+Xdebug 安装教程(vscode用debug的调试php)
环境:window10 + phpstudy+vscode
php全篇用php8.0.2,也可以用其他的版本,但要注意所有配置路径都要统一版本
一、环境变量
将你正在使用的php加入环境变量。因为phpstudy默认是没有将php加入环境变量的
二、phpstudy设置
1.php要安装xdebug拓展
2.phpstudy设置php。端口监听最好改9003或其他没被暂用的(nginx一般占用9000或9001)
3.修改php配置。按图找或者自己去查找文件地址
[Xdebug]
zend_extension=D:/phpstudy_pro/Extensions/php/php8.0.2nts/ext/php_xdebug.dll
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.auto_trace=On
xdebug.trace_output_dir=D:/phpstudy_pro/Extensions/php_log/php8.0.2nts.xdebug.trace
xdebug.profiler_enable=On
xdebug.profiler_output_dir ="D:\phpstudy_pro\Extensions\tmp\xdebug"
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.remote_enable=1
xdebug.remote_autostart = 1
xdebug.remote_host=localhost
xdebug.remote_port=9003
xdebug.remote_handler=dbgp
xdebug.mode = debug
xdebug.start_with_request = yes
注意:红色为vscode插件php debug 2.0版本的配置,绿色的为 php debug 3.0版本
三、vscode设置
1.修改vscode配置
"php.validate.executablePath": "D:\\phpstudy_pro\\Extensions\\php\\php8.0.2nts\\php.exe", "php.debug.executablePath": "D:\\phpstudy_pro\\Extensions\\php\\php8.0.2nts\\php.exe",
2.安装插件
3.添加配置
{ "configurations": [ { "name": "Launch current script in console", "type": "php", "request": "launch", "program": "${file}", "cwd": "${fileDirname}", "externalConsole": false, "port": 9001 }, { "name": "Listen for XDebug", "type": "php", "request": "launch", "port": 9001 } ] }

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端