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

 

最后调试

 

 

 
posted @   会飞的鹏  阅读(981)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端
点击右上角即可分享
微信分享提示