当前位置: 首页 > article >正文

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 目录,第一条是 提示的,剩余的都是必须要写的

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 配置

{
    "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 ;
在这里插入图片描述


http://www.kler.cn/a/145894.html

相关文章:

  • 在 Ubuntu 上安装最新版的 Calibre
  • ElasticSearch之禁用交换分区
  • 数据结构 / 顺序表的遍历
  • 云匣子 FastJson反序列化RCE漏洞复现
  • 京东数据分析(京东大数据):2023年10月京东手机行业品牌销售排行榜
  • 初学vue3与ts:setup与setup()下的数据写法
  • Blender快捷键总结
  • vs2015如何远程启动程序来进行调试
  • Vue轻松入门,附带学习笔记和相关案例
  • Retrofit怎么返回一个JSON字符串?
  • TS常见类型概述
  • 1. 图的广度优先遍历
  • docker 常用容器创建(自用)
  • 操作系统题目分类总结 | 进程管理 内存管理 文件系统 设备管理
  • 2023/11/26总结
  • 5 动态规划解分割等和子串
  • bootstrap 5 登录、注册页面
  • Java小游戏“简易版王者荣耀”
  • YOLOV7主干改进,使用fasternet轻量化改进主干(完整教程)
  • 人工智能|机器学习——循环神经网络的简洁实现