vscode配置xdebug断点调试详细教程

注:环境为本地windows开发环境,编辑器为vscode,PHP集成环境工具为EServer

vscode安装扩展并配置

安装PHP Debug

扩展中搜索 PHP Debug 并安装:

配置PHP Debug

1、点击扩展设置

2、在设置中,点击 setting.json

3、编辑 setting.json ,主要配置下 php.validate.executablePathphp.debug.executablePath ,配置为你本地 php 目录,以下是完整内容:

请注意端口,要与后面的 php.ini 中的端口相同,例如在该配置中 port 为9003,php.ini 中设置也要为9003

php 复制代码
{
    "php.validate.executablePath": "E:\\EServer\\core\\software\\php\\php-7.4\\php.exe", // 不要直接cody,需要配置为你本地php目录
    "php.executablePath": "E:\\EServer\\core\\software\\php\\php-7.4\\php.exe", // 不要直接cody,需要配置为你本地php目录
    "workbench.colorTheme": "Visual Studio Light",
    "editor.fontSize": 18,
    "window.zoomLevel": 1,
    "git.suggestSmartCommit": false,
    "workbench.iconTheme": "vs-minimal",
    "intelephense.phpdoc.classTemplate": {

        "summary": "$1",
        "tags": [
            "@package ${1:$SYMBOL_NAMESPACE}"
        ]
    },
    "editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?",
    "php.debug.executablePath": "E:\\EServer\\core\\software\\php\\php-7.4\\php.exe", // 不要直接cody,需要配置为你本地 php 目录
    "launch": {
        "configurations": [
            {
                "name": "Listen for XDebug",
                "type": "php",
                "request": "launch",
                "port": 9003
            },
            {
                "name": "Launch currently open script",
                "type": "php",
                "request": "launch",
                "program": "${file}",
                "cwd": "${fileDirname}",
                "port": 9003
            }
        ],
        "compounds": []
    }
}

安装xdebug并配置

我这里使用的工具为 EServer ,其他工具请自行搜索安装 xdebug ,以下为 EServer 的扩展安装方法:

找到 xdebug 扩展直接点击安装即可

安装完成后,打开对应php版本的 php.ini 文件:

配置php.ini:

php 复制代码
[Xdebug]
zend_extension = php_xdebug.dll
xdebug.remote_enable = On
xdebug.remote_autostart = On // 需要新增该配置
xdebug.remote_host = localhost
xdebug.remote_port = 9003 // 注意端口号要与前面xdebug中的配置相同

完成

添加断点,并按 F5 开启debug:

访问 url ,即可看到断点内容了。

相关推荐
安大小万12 小时前
VSCode的json文件不允许注释的解决办法
ide·vscode·编辑器
阿洛学长12 小时前
更好用的Wordpress二次元主题!Mokore更新1.2啦
php
AIBox36513 小时前
Claude 中转站怎么接入:2026 年国内调用 Claude API 的方法、能力与示例
服务器·开发语言·人工智能·gpt·php·python3.11
gskyi14 小时前
libvips相比GD与Imagick的性能优势
php·imagen
拉不拉斯14 小时前
vsCode远程连接Centos 7出现的错误以及解决办法
ide·vscode·centos
wild-civil14 小时前
解决Keil 生成的文件在 VSCode 乱码问题(自动识别,不用手动改编码)
ide·vscode·stm32·编辑器
ooseabiscuit1 天前
Laravel4.x:现代PHP框架的奠基之作
java·开发语言·php
ooseabiscuit1 天前
Laravel 1.x:揭秘PHP框架的起源与设计
php·laravel
m0_738120721 天前
ctfshow靶场SSRF部分——基础绕过到协议攻击解题思路与技巧(一)
服务器·前端·网络·安全·php
幽络源小助理1 天前
最新短网址系统源码 分用户链接 - 幽络源免费源码分享
前端·php