【问题标题】:Telescope receiving empty responses even though there are records in the database that it should show望远镜收到空响应,即使数据库中有记录应该显示
【发布时间】:2020-08-04 07:39:47
【问题描述】:

Telescope 不显示telescope_entries 表中的任何记录,而是仅显示以下内容:

如果我们查看浏览器控制台,我们会看到 Telescope 经常向其 API 发送 POST 请求,但收到一个空的条目数组:

我确定数据库中有记录,因为我可以使用我的数据库查看器查看它们:

此外,当我在 Tinker 中运行 DB::table("telescope_entries")->get() 时,我会从数据库中获取正确的记录。

出于调试目的,我在EntryControllerindex 方法的return 语句之前添加了lad([$request, $storage]);

public function index(Request $request, EntriesRepository $storage)
{
    lad([$request, $storage]); // function comes from lanin/laravel-api-debugger
    return response()->json([
        'entries' => $storage->get(
            $this->entryType(),
            EntryQueryOptions::fromRequest($request)
        ),
        'status' => $this->status(),
    ]);
}

现在,当浏览器向 Telescope 的 API 发送请求时,它会收到以下 JSON:

{
    "entries": [],
    "status": "enabled",
    "debug": {
        "database": {
            "total": 1,
            "items": [
                {
                    "connection": "sqlite",
                    "query": "select * from \"telescope_entries\" where \"type\" = 'request' and \"should_display_on_index\" = '1' order by \"sequence\" desc limit 50;",
                    "time": 7.68
                }
            ]
        },
        "cache": {
            "hit": {
                "keys": [],
                "total": 0
            },
            "miss": {
                "keys": [
                    "telescope:dump-watcher",
                    "telescope:pause-recording"
                ],
                "total": 2
            },
            "write": {
                "keys": [],
                "total": 0
            },
            "forget": {
                "keys": [],
                "total": 0
            }
        },
        "profiling": [
            {
                "event": "request-time",
                "time": 0.6450369358062744
            }
        ],
        "memory": {
            "usage": 16327024,
            "peak": 16547112
        },
        "dump": [
            [
                {
                    "attributes": {},
                    "request": {},
                    "query": {},
                    "server": {},
                    "files": {},
                    "cookies": {},
                    "headers": {}
                },
                {}
            ]
        ]
    }
}

当我在我的数据库查看器中运行上面提供的 SQL 语句时,我收到了我应该收到的记录:

这个问题似乎与数据库无关。我连接到外部 PostgreSQL 数据库以及本地 SQLite 数据库,但发生了同样的问题。

自从我第一次开始使用 Laravel 以来,我就一直坚持这一点,实际上我对此无能为力。我在 Telescope 的 GitHub 上发布了一个问题,但它被关闭了,因为“它对其他人有用”。

我为重现此问题而采取的步骤:

  1. 创建了一个新的 Laravel 项目
  2. .env文件中的DB_CONNECTION变量设置为sqlite
  3. /database 文件夹中创建了一个名为database.sqlite 的新文件
  4. 运行命令:
    1. composer require laravel/telescope
    2. php artisan telescope:install
    3. php artisan migrate

另外,我没有参与制作,也没有做以上任何事情。如果我使用其他人创建的项目,望远镜对我也不起作用,但对那个人来说它可以工作。

感谢任何帮助!

【问题讨论】:

    标签: laravel


    【解决方案1】:

    解决这个问题的方法是在 Homestead 上运行 Laravel。我可能错过了某种包裹,我太累了,无法调查。我可以推荐一个我用来学习的教程:

    https://www.youtube.com/watch?v=n2RAArt1GRI

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-14
      • 1970-01-01
      • 1970-01-01
      • 2013-10-06
      • 2015-05-10
      • 2021-07-08
      • 1970-01-01
      相关资源
      最近更新 更多