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 ;

相关推荐
老菜鸟YDZ4 小时前
二十多年前的苹果电源Power Mac G4 Mdd 电源接口
macos·接口定义·mdd·power mac g4·studio display·m2454·苹果电源
鸡啄米的时光机7 小时前
vscode的一些实用操作
vscode·学习
肉小盾9 小时前
编译安装php
开发语言·php
Dest1ny-安全9 小时前
Dest1ny漏洞库: 美团代付微信小程序系统任意文件读取漏洞
微信小程序·小程序·php
寰宇软件10 小时前
PHP图书借阅小程序
小程序·uni-app·vue·php
灰色人生qwer11 小时前
React + TypeScript+ Vite 配置路径别名和vscode智能路径提示
vscode·react.js·typescript
anthonyzhu11 小时前
Mac本地部署deepseek
macos
LOLA444411 小时前
解压包格式7z怎么解压?8种方法(Win/Mac/手机/网页端)
macos·软件需求
莲动渔舟11 小时前
赶AI大潮:在VSCode中使用DeepSeek及近百种模型的极简方法
ide·人工智能·vscode·deepseek
木兰不吃草11 小时前
如何在 Mac 上下载安装仙剑游戏仙剑世界?可以通过IPA砸壳包安装非常简单
游戏·macos·ios·游戏程序·mac