The Redis class is built-in to Laravel and connection() is there. It can't be missing. You might have installed php-redis on your system. Redis can be another class into php-redis. So there may conflict between Laravel Redis alias and another Redis class.
Now there are two solutions for solving this problem.
- You just need to edit your app config, open app/config/app.php and replace this line:
1 2 3 |
'Redis' => 'Illuminate\Support\Facades\Redis', To 'LaravelRedis' => 'Illuminate\Support\Facades\Redis', |
And then you can get your Redis instance like this:
1 |
$redis = LaravelRedis::connection(); |
2. Remove php-redis
To remove the php-redis you need to run the below command:
1 |
sudo apt-get remove --auto-remove php-redis |
Now restart your Redis server by following command:
1 |
/etc/init.d/redis-server restart |
...