我在 Laravel 5.2 中收到错误“找不到类‘Predis\Client’”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34865064/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I'm getting error "Class 'Predis\Client' not found" in Laravel 5.2
提问by onerciller
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.
我想在 laravel 5.2 中使用 Redis 但是,我收到错误,例如找不到“Predis\Client”类,我该如何解决。
回答by Abhishek
- First download the REDISto 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.
回答by Kamil Kie?czewski
Write in console in project folder:
在项目文件夹中的控制台中写入:
composer require predis/predis
And thats all.
就这样。
回答by Marcin Nabia?ek
You need to add predis/predis
into composer.json
for your project. Reference: https://laravel.com/docs/5.2/redis#introduction
你需要为你的项目添加predis/predis
进去composer.json
。参考:https: //laravel.com/docs/5.2/redis#introduction
回答by Vinod Kumar Pal
we have add composer.json file "predis/predis": "~1.0" help working fine.
我们添加了 composer.json 文件 "predis/predis": "~1.0" 帮助工作正常。
回答by Karl Johan Vallner
Btw, if you are using laravel workers, with ubuntu supervisor and this error will not dissappear even after you did
顺便说一句,如果您使用的是 laravel 工作人员,则与 ubuntu 主管一起使用,即使您这样做,此错误也不会消失
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
然后记住孩子们,一旦你启动它,主管就会缓存你所有的 php 代码。因此,在您启动主管工作人员(https://laravel.com/docs/5.6/queues#supervisor-configuration)后安装 predis不会产生任何影响,直到您这样做
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.
去年,我在 3 个项目上被困在这个问题上一两个小时。
回答by Mwatha Kinyua
Running composer dump
after installing predis/predis package might be necessary
composer dump
可能需要在安装 predis/predis 包后运行
回答by PeterPi
I solved the problem just including the use Predis;
above class file in app folder.
我解决了这个问题,只是use Predis;
在 app 文件夹中包含了上面的类文件。
If you installed predis via composer require predis/predis already.
如果您通过 composer 安装了 predis,则需要 predis/predis。