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 ;

相关推荐
敖行客 Allthinker6 小时前
VS Code 智能代理模式:重塑开发体验
vscode·代理模式
請你喝杯Java6 小时前
Mac上Cursor无法安装插件解决方法
macos·cursor·vsode
帅云毅7 小时前
文件上传--解析漏洞和编辑器
笔记·学习·安全·web安全·编辑器·php
PyAIGCMaster8 小时前
Vscode已经打开的python项目,如何使用已经建立的虚拟环境
ide·vscode·python
wt_cs8 小时前
身份证实名认证接口数字时代的信任基石-node.js实名认证集成
开发语言·node.js·php
编程猪猪侠8 小时前
VSCode如何修改默认扩展路径和用户文件夹目录到其他盘以及微信开发工具如何修改扩展路径到其他盘
ide·vscode·编辑器
网络之路Blog9 小时前
【实战中提升自己】内网安全部署之端口隔离与MAC地址认证
安全·macos·网络之路一天·华为华三数通基础·华为华三企业实战架构·华为中小型企业实战·华为华三计算机网络基础
心随_风动9 小时前
主流操作系统对比分析(macOS、Linux、Windows、Unix)
linux·windows·macos
姜太小白9 小时前
【VSCode】VS Code自动换行设置方法
ide·vscode·编辑器
lxw184491251410 小时前
macOS 系统设置息屏情况下,PHP等后台脚本继续执行
macos