xampp+vscode 安装PHP断点调试xdebug

官网下载地址:https://xdebug.org/download.php 

这里需要特别注意,有TS(thread safe)和NTS 区别,我建议不要下载最新的,我一开始使用最新的发现插件没有匹配上,走了好大一段弯路,想想都难过

可以使用官方的工具去找到适合自己的工具:https://xdebug.org/wizard.php

 下载该版本后把XDebug.dll文件放到php的ext目录,配置php.ini文件如下

 

配置到此可以通过 php -v 查看配置是否成功

 

OK,现在到了VSCode里的插件下载和配置环节

配置PHP路径信息

 

 安装拓展

 launch.json文件:

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9000
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000,
            "runtimeArgs": [
                "-dxdebug.start_with_request=yes"
            ],
            "env": {
                "XDEBUG_MODE": "debug,develop",
                "XDEBUG_CONFIG": "client_port=${port}"
            }
        },
        {
            "name": "Launch Built-in web server",
            "type": "php",
            "request": "launch",
            "runtimeArgs": [
                "-dxdebug.mode=debug",
                "-dxdebug.start_with_request=yes",
                "-S",
                "localhost:0"
            ],
            "program": "",
            "cwd": "${workspaceRoot}",
            "port": 9000,
            "serverReadyAction": {
                "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
                "uriFormat": "http://localhost:%s",
                "action": "openExternally"
            }
        }
    ]
}

  

posted @ 2023-10-14 21:05  飞龙在生  阅读(145)  评论(0编辑  收藏  举报