When I'm try to use redis on my project laravel 6.x it show this error message

Viewed 8298

ERROR:

Please remove or rename the Redis facade alias in your "app" configuration file in order to avoid collision with the PHP Redis extension

image

I put this code on my cache.php

'default' => env('CACHE_DRIVER', 'redis'),

And those code in my controller:

$data['posts']   = cache('posts',function(){
      Post::with('user')
          ->select('title', 'created_at', 'user_id', 'thumbnail_path', 'content')
          ->orderBy('created_at','desc')
          ->take(50)
          ->get();
});
2 Answers

Firstly, you need to make sure you have actually installed predis using composer by running this in your terminal: composer require predis/predis

And then you need to make sure that your have this set in your .env file REDIS_CLIENT=predis

This is covered in the docs: https://laravel.com/docs/6.x/redis

I got this error message when I hosted my Laravel app on cloudways.com. I fixed it by installing Redis and Supervisord from the server 'Settings & Packages' page.

Related