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

2

6

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();
});
Backdrop answered 12/10, 2019 at 13:25 Comment(0)
M
23

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

Montagna answered 12/10, 2019 at 13:53 Comment(1)
Did you cleared the cache? Try php artisan config:clear && php artisan config:cache && php artisan cache:clearInterlunar
A
1

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.

Armenian answered 2/7, 2020 at 9:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.