【发布时间】:2020-08-04 07:39:47
【问题描述】:
Telescope 不显示telescope_entries 表中的任何记录,而是仅显示以下内容:
如果我们查看浏览器控制台,我们会看到 Telescope 经常向其 API 发送 POST 请求,但收到一个空的条目数组:
我确定数据库中有记录,因为我可以使用我的数据库查看器查看它们:
此外,当我在 Tinker 中运行 DB::table("telescope_entries")->get() 时,我会从数据库中获取正确的记录。
出于调试目的,我在EntryController 的index 方法的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 上发布了一个问题,但它被关闭了,因为“它对其他人有用”。
我为重现此问题而采取的步骤:
- 创建了一个新的 Laravel 项目
- 将
.env文件中的DB_CONNECTION变量设置为sqlite - 在
/database文件夹中创建了一个名为database.sqlite的新文件 - 运行命令:
composer require laravel/telescopephp artisan telescope:installphp artisan migrate
另外,我没有参与制作,也没有做以上任何事情。如果我使用其他人创建的项目,望远镜对我也不起作用,但对那个人来说它可以工作。
感谢任何帮助!
【问题讨论】:
标签: laravel