mac VScode 添加PHP debug

在VScode里面添加PHP Debug 插件,根据debug描述内容操作
1: 随意在index里面写个方法,然后用浏览器访问你的hello 方法,正常会进入下边的内容

class IndexController
{
    public function index()
    {
        return '您好!这是一个[api]示例应用';
    }

    public function hello() 
    {
        phpinfo();
    }
}

2 ctrl+A,全选复制内容,然后复制到https://xdebug.org/wizard

3 点击红框的按钮

4 按照内容一步一步操作,英语不好的,自己百度吧下载好的不用放在其他地方,放到桌面也行

1 下载xdebug,2 如果安装了php就不需要重新安装了,3 解压文件,4 使用命令行进入这个目录

5 输入phpize
6 输入./configure

7 输入 make

8 tips:我用的是Eserver部署的,提示和你们部署环境不一样,你们就复制从'cp...' 开始输入

9 打开php.ini 目录,第一条是 提示的,剩余的都是必须要写的

bash 复制代码
zend_extension = xdebug
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9001
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

10 重启php,和 服务器

第二部:vscode 里面的launch.json 配置

bash 复制代码
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9001
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9001,
            "runtimeArgs": [
                "-dxdebug.start_with_request=yes"
            ],
            "env": {
                "XDEBUG_MODE": "debug,develop",
                "XDEBUG_CONFIG": "client_port=${port}",
                "XDEBUG_SESSION": "1"
            }
        },
        {
            "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": 9001,
            "serverReadyAction": {
                "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
                "uriFormat": "http://localhost:%s",
                "action": "openExternally"
            }
        }
    ]
}

接下来就是测试了,在浏览器输入 你的访问地址/index/hello ;

相关推荐
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
吃汤圆的抹香鲸1 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
网安-轩逸3 小时前
网络安全防御模型
安全·web安全·php
甜于酸12 小时前
MuMu模拟器Pro for Mac 安卓手机平板模拟器
android·macos·智能手机
渔夫阿布13 小时前
在MAC上面通过HomeBrew安装node和npm@指定版本
前端·macos·npm
waicsdn_haha13 小时前
TeX Live 2025 最新版安装与中文环境配置全教程(Windows/Mac/Linux)
linux·windows·macos·论文笔记·sublime text·mdk·嵌入式开发工具
白云千载尽15 小时前
ubuntu环境中安装latex并使用vscode
linux·vscode·ubuntu
Jelena技术达人15 小时前
爬虫获取翻译文本接口:技术实现与应用实践
爬虫·python·php
xinyu39118 小时前
iOS Framework代码中加载图片资源
macos·ios·cocoa
XiYang-DING20 小时前
【计网】计算机网络概述
服务器·计算机网络·php