vscode 配置xdebug

复制 phpinfo信息到 https://xdebug.org/wizard ,根据结果下载xdebug

image.png

将下载好的dll扩展放到php的ext目录下并重命名xdebug.dll


image.png

打开php.ini配置文件在最下面增加

[XDebug]
 zend_extension = xdebug
 xdebug.mode=debug
 xdebug.start_with_request=yes
 xdebug.client_host=127.0.0.1
 xdebug.port=9003

打开vscode 添加插件php debug


image.png

配置xdebug的环境


image.png
{
    "version":"0.2.0",
    "configurations": [
        {
            "name": "Launch current script in console",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "externalConsole": false,
            "port": 9003
        },
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9003
        }
    
    ]
}

配置vscode


image.png

增加


image.png
{
    "security.workspace.trust.untrustedFiles": "open",
    "editor.multiCursorLimit": 20000,
    "extensions.ignoreRecommendations": true,
    "tabnine.experimentalAutoImports": true,
    "go.alternateTools": {},
    "workbench.editorAssociations": {
        "*.cap": "default"
    },
    "diffEditor.ignoreTrimWhitespace": false,
    "settingsSync.ignoredExtensions": [],
    "php.debug.executablePath": "C:\\phpstudy_pro\\Extensions\\php\\php8.0.30nts\\php.exe",
    "php.validate.executablePath": "C:\\phpstudy_pro\\Extensions\\php\\php8.0.30nts\\php.exe",
    "explorer.confirmDelete": false
}

重启vscode后,任意位置打断点


image.png

点击启动按钮


image.png

控制台中可看到监听中


image.png

在浏览器中访问该地址
在vscode中即可看到对应调试信息
image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容