I'm getting error “Class 'Predis\Client' not found” in Laravel 5.2

情到浓时终转凉″ 提交于 2019-12-17 16:00:19

问题


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.


回答1:


  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.




回答2:


Write in console in project folder:

composer require predis/predis

And thats all.




回答3:


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




回答4:


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




回答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.




回答6:


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




回答7:


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.



来源:https://stackoverflow.com/questions/34865064/im-getting-error-class-predis-client-not-found-in-laravel-5-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!