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 @ 2023-01-05 19:32  会飞的鹏  阅读(845)  评论(0编辑  收藏  举报