I'm getting error "Class 'Predis\Client' not found" in Laravel 5.2
Asked Answered
O

10

61

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.

Opisthognathous answered 18/1, 2016 at 22:15 Comment(2)
Your explanation is not sufficient to solve the problem. Check this link stackoverflow.com/help/how-to-askAnnunciator
@Annunciator for me this explanation was sufficient - question was precise and clear.Violist
A
85
  1. First download the REDIS to your system (if you haven't already installed it).
  2. Go to the folder where you have downloaded the redis and run this command:

    cd your-redis-folder-name
    make
    
  3. Go to your project directory and install composer:

    composer require predis/predis

  4. Go to your .env file and add Queue driver:

    QUEUE_DRIVER=redis
    
  5. use Mail::queue() to send mail via queue. See Doc.
  6. And in your terminal run:

    php artisan queue:listen 
    

    to send.

Aroma answered 19/1, 2016 at 7:20 Comment(1)
what does cd your-redis-folder-name make mean? when I do this it throws:: The term 'make' is not recognized as the name of a cmdlet. and when I write cd my-redis-extracted-folders make it errors A positional parameter cannot be found that accepts argument 'make'.Gona
P
45

Write in console in project folder:

composer require predis/predis

And thats all.

Periodate answered 5/8, 2016 at 10:37 Comment(0)
P
8

You need to add predis/predis into composer.json for your project. Reference: https://laravel.com/docs/5.2/redis#introduction

Pyrosis answered 18/1, 2016 at 23:14 Comment(0)
F
5

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.

Fancher answered 12/6, 2018 at 4:52 Comment(0)
C
4

we have add composer.json file "predis/predis": "~1.0" help working fine.

Crunode answered 21/5, 2016 at 12:41 Comment(0)
H
2

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

Hygrophilous answered 14/10, 2021 at 18:41 Comment(0)
F
1

I solved the problem just including the use Predis; above class file in app folder.

If you installed predis via composer require predis/predis already.

Felicity answered 30/10, 2019 at 9:36 Comment(0)
R
0

Running composer dump after installing predis/predis package might be necessary

Rone answered 14/12, 2018 at 13:59 Comment(0)
R
0

It's easy to just look at the path and filename Examples that exist Most of the path name or autoload file name are not spelled correctly

1-go to https://github.com/predis/predis/tags

2-create folder in host by name redis

3-download predis and upload to your website dir (www) in redis

4- create index.php out of the predis folder(redis)

5- past this code for test in index.php

require 'redis/Autoload.php';
Predis\Autoloader::register();
$client = new Predis\Client();
$client->set('foo', 'bar');
$value = $client->get('foo');
echo $value;
Resuscitate answered 9/2, 2022 at 6:34 Comment(0)
U
0

My issue was that I updated the .env file through Envoyer to use redis as the session and cache drivers prior to deploying the composer lock file. This was causing composer install to fail on deployment.

Resolved by changing the session and cache drivers back to file, then deploying the updated composer lock file and running composer install, then updated the session and cache drivers back in the .env file back to redis and redeployed again.

Undying answered 6/7, 2022 at 3:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.