某个用户的详情接口调用时出现 Call to a member function connect() on null 错误?

1. 运行环境

Homestead [v12.1.0]

1). 当前使用的 Laravel 版本?

Laravel Framework 8.76.2

2). 当前使用的 php/php-fpm 版本?

PHP 版本:

php-fpm 版本:

某个用户的详情接口调用时出现 Call to a member function connect() on null 错误?

3). 当前系统

macOS Mojave

4). 业务环境

开发环境

2. 问题描述?

某个用户的详情接口调用时出现 Call to a member function connect() on null 错误

某个用户的详情接口调用时出现 Call to a member function connect() on null 错误?

routes/api.php

.
.
.
// 某个用户的详情
Route::get('users/{user}', 'UsersController@show')->name('users.show');

app/Http/Controllers/Api/UsersController.php

.
.
.
public function show(User $user, Request $request)
{
    return new UserResource($user);
}

3. 您期望得到的结果?

某个用户的详情接口调用时出现 Call to a member function connect() on null 错误?

4. 您实际得到的结果?


local.ERROR: Call to a member function connect() on null {"exception":"[object] (Error(code: 0): Call to a member function connect() on null at /home/vagrant/Code/l8api/vendor/laravel/framework/src/Illuminate/Redis/RedisManager.php:110)
[stacktrace]
#0 /home/vagrant/Code/l8api/vendor/laravel/framework/src/Illuminate/Redis/RedisManager.php(91): Illuminate\\Redis\\RedisManager->resolve()
#1 /home/vagrant/Code/l8api/vendor/laravel/framework/src/Illuminate/Redis/RedisManager.php(277): Illuminate\\Redis\\RedisManager->connection()
"} 
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
最佳答案

你好
看报错应该是 redis 连接出错了,请问是否检查过 redis 配置?

3年前 评论
AllenBool (楼主) 3年前
AllenBool (楼主) 3年前
MArtian (作者) 3年前
讨论数量: 4

你好
看报错应该是 redis 连接出错了,请问是否检查过 redis 配置?

3年前 评论
AllenBool (楼主) 3年前
AllenBool (楼主) 3年前
MArtian (作者) 3年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!