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
        }
    
    ]
}
复制代码

 

最后调试

 

 

posted @ 2024-03-02 15:09  吖水的程序路  阅读(63)  评论(0编辑  收藏  举报