VScode 配置php调试环境变量. phpstudy + nginx+ php7.4, 解决无法断点问题
参考大佬的帖子
https://www.cnblogs.com/hfdp/p/17028596.html
https://blog.csdn.net/qq_61739597/article/details/132433472 (远程调试)
踩坑经验
我从phpstudy 添加好网站才进行配置. 当配置好之后,一直没有断点下来. 非常郁闷找不到问题.
写了一个demo, php文件, 通过phpstudy添加网站发现可以断点下来
后来果断重新添加一下网站,, 问题解决
环境: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 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!