I want to using Redis in laravel 5.2 however, I'm getting error such a Class 'Predis\Client' not found, How I can solve it.
8 Answers
- First download the REDIS to your system (if you haven't already installed it).
Go to the folder where you have downloaded the redis and run this command:
cd your-redis-folder-name make
Go to your project directory and install composer:
composer require predis/predis
Go to your .env file and add Queue driver:
QUEUE_DRIVER=redis
- use
Mail::queue()
to send mail via queue. See Doc. And in your terminal run:
php artisan queue:listen
to send.
You need to add predis/predis
into composer.json
for your project. Reference: https://laravel.com/docs/5.2/redis#introduction
Btw, if you are using laravel workers, with ubuntu supervisor and this error will not dissappear even after you did
composer require predis/predis
Then remember kids, that supervisor caches all your php code, once you boot it. So installing predis after you booted supervisor workers (https://laravel.com/docs/5.6/queues#supervisor-configuration), will not make a difference, until you do
sudo supervisorctl stop laravel-worker:*
and then start it again
sudo supervisorctl start laravel-worker:*
I've been stuck on this for an hour or two, on 3 projects in the last year.
you can also try to run Redis as a local server, download this and run the run Redis server
file
if you still get it use composer require predis/predis