【无标题】

VScode远程调试PHP代码
1、vscode下载插件:phpDebug、phpXdebug、remote-SSH插件
【无标题】_第1张图片
【无标题】_第2张图片
【无标题】_第3张图片

2、安装好上述的模块后,打开vscode,点击旁边或者左下角的><按钮,然后选择Connect to Host,输入ssh 登陆的用户名@ip地址(每次登陆都需输入密码,或者进行密钥登录(需配置))
【无标题】_第4张图片
安装好后点击运行与调试,创建launch.json文件

"version": "0.2.0",
    "configurations": [
        {
            "name": "Debug current script in console",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "externalConsole": false,
            "port": 9004
        },
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9004
        }

xdebug配置
先进入/etc/php/8.1/fpm/conf.d/20-xdebug.ini
写入内容这里的端口与你改的端口要一致

zend_extension=xdebug.so
[XDebug]
xdebug.remote_enable = on
xdebug.start_with_request = 1
xdebug.mode=trace
xdebug.collect_includes = 1
xdebug.collect_params = 1
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9004
xdebug.start_with_request=yes
xdebug.remote_log=/var/log/xdebug.log

你可能感兴趣的:(php)