Laravel Version: 7.5.0
PHP Version: 7.2
Database Driver & Version: Redis
Everything was working fine but suddenly this error appear i changed the phpredis to predis but error is same.
Steps To Reproduce:
I am calling the event function event(new ChatsEvent($data));
LogicException: Please make sure the PHP Redis extension is installed and enabled. in /home/user/public_html/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:76
Stack trace:
#0 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Support/helpers.php(428): IlluminateRedisConnectorsPhpRedisConnector->IlluminateRedisConnectors{closure}(Object(IlluminateSupportFacadesRedis))
#1 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php(104): tap(Object(IlluminateSupportFacadesRedis), Object(Closure))
#2 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php(27): IlluminateRedisConnectorsPhpRedisConnector->createClient(Array)
#3 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php(31): IlluminateRedisConnectorsPhpRedisConnector->IlluminateRedisConnectors{closure}()
#4 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Redis/RedisManager.php(111): IlluminateRedisConnectorsPhpRedisConnector->connect(Array, Array)
#5 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Redis/RedisManager.php(90): IlluminateRedisRedisManager->resolve('default')
#6 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php(108): IlluminateRedisRedisManager->connection('default')
#7 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php(64): IlluminateBroadcastingBroadcastersRedisBroadcaster->broadcast(Array, 'ChatsEvent', Array)
#8 [internal function]: IlluminateBroadcastingBroadcastEvent->handle(Object(IlluminateBroadcastingBroadcastersRedisBroadcaster))
#9 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#10 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Container/Util.php(36): IlluminateContainerBoundMethod::IlluminateContainer{closure}()
#11 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): IlluminateContainerUtil::unwrapIfClosure(Object(Closure))
#12 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): IlluminateContainerBoundMethod::callBoundMethod(Object(IlluminateFoundationApplication), Array, Object(Closure))
#13 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Container/Container.php(592): IlluminateContainerBoundMethod::call(Object(IlluminateFoundationApplication), Array, Array, NULL)
#14 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): IlluminateContainerContainer->call(Array)
#15 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): IlluminateBusDispatcher->IlluminateBus{closure}(Object(IlluminateBroadcastingBroadcastEvent))
#16 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): IlluminatePipelinePipeline->IlluminatePipeline{closure}(Object(IlluminateBroadcastingBroadcastEvent))
#17 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): IlluminatePipelinePipeline->then(Object(Closure))
#18 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(83): IlluminateBusDispatcher->dispatchNow(Object(IlluminateBroadcastingBroadcastEvent), false)
#19 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): IlluminateQueueCallQueuedHandler->IlluminateQueue{closure}(Object(IlluminateBroadcastingBroadcastEvent))
#20 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): IlluminatePipelinePipeline->IlluminatePipeline{closure}(Object(IlluminateBroadcastingBroadcastEvent))
#21 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(85): IlluminatePipelinePipeline->then(Object(Closure))
#22 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(59): IlluminateQueueCallQueuedHandler->dispatchThroughMiddleware(Object(IlluminateQueueJobsDatabaseJob), Object(IlluminateBroadcastingBroadcastEvent))
#23 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): IlluminateQueueCallQueuedHandler->call(Object(IlluminateQueueJobsDatabaseJob), Array)
#24 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(356): IlluminateQueueJobsJob->fire()
#25 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(306): IlluminateQueueWorker->process('database', Object(IlluminateQueueJobsDatabaseJob), Object(IlluminateQueueWorkerOptions))
#26 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(132): IlluminateQueueWorker->runJob(Object(IlluminateQueueJobsDatabaseJob), 'database', Object(IlluminateQueueWorkerOptions))
#27 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(112): IlluminateQueueWorker->daemon('database', 'default', Object(IlluminateQueueWorkerOptions))
#28 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(96): IlluminateQueueConsoleWorkCommand->runWorker('database', 'default')
#29 [internal function]: IlluminateQueueConsoleWorkCommand->handle()
#30 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#31 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Container/Util.php(36): IlluminateContainerBoundMethod::IlluminateContainer{closure}()
#32 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): IlluminateContainerUtil::unwrapIfClosure(Object(Closure))
#33 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): IlluminateContainerBoundMethod::callBoundMethod(Object(IlluminateFoundationApplication), Array, Object(Closure))
#34 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Container/Container.php(592): IlluminateContainerBoundMethod::call(Object(IlluminateFoundationApplication), Array, Array, NULL)
#35 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Console/Command.php(134): IlluminateContainerContainer->call(Array)
#36 /home/user/public_html/vendor/symfony/console/Command/Command.php(255): IlluminateConsoleCommand->execute(Object(SymfonyComponentConsoleInputArgvInput), Object(IlluminateConsoleOutputStyle))
#37 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): SymfonyComponentConsoleCommandCommand->run(Object(SymfonyComponentConsoleInputArgvInput), Object(IlluminateConsoleOutputStyle))
#38 /home/user/public_html/vendor/symfony/console/Application.php(912): IlluminateConsoleCommand->run(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#39 /home/user/public_html/vendor/symfony/console/Application.php(264): SymfonyComponentConsoleApplication->doRunCommand(Object(IlluminateQueueConsoleWorkCommand), Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#40 /home/user/public_html/vendor/symfony/console/Application.php(140): SymfonyComponentConsoleApplication->doRun(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#41 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): SymfonyComponentConsoleApplication->run(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#42 /home/user/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): IlluminateConsoleApplication->run(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#43 /home/user/public_html/artisan(36): IlluminateFoundationConsoleKernel->handle(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#44 {main}
10
Answers
I have some problem dude, but i was solved this problem. Try and learn (My OS is Linux):
Step 1: Install PhpRedis
In order to install the latest version of the PhpRedis extension, we can use pecl. To install pecl you need to install the PHP Extension and Application Repository or PEAR for short:
Step 2: Then you might also have to install the PHP Dev tools:
Step 3: Then we would want to go ahead and install this package here. To do that, just run:
Finally: Make sure that you enable the new PHP extension by adding the following line to your php.ini and if you are not finded this script, you can write this script under the list of all
extension=
And don’t forget to restart your apache2 service by:
Good luck dude!
Php redis extension is missing.
There are two ways:
REDIS_CLIENT
in .env) and install predis composer package (composer require predis/predis
).But
predis
little bit slower thatphpredis
.P.S.: (for way number 1): After installing phpredis extension you need to add this to
composer.json
intorequire
section as"ext-redis": "*"
for proper deployments. See about composer platform requirements.If you’re in windows add the dependency of predis using this
composer require predis/predis
command.Then configure your .env file like this
I’m using redis for queueing my mail’s.So I set
QUEUE_CONNECTION=redis
andREDIS_CLIENT=predis
.This works fine when you’re developing locally .In production its same but little bit differentIf you are using Heroku or another PaaS platform, there is a high chance that you need to add Redis extension to your composer requirements:
In case you install Redis with
composer require predis/predis
, you need to add this line to.env
file:Then clear cache by run this command:
php artisan optimize:clear
An additional way
you can change this line inconfig/database.php
file:From:
To:
Then clear cache by run this command:
php artisan optimize:clear
For My case I just install php extension in my ubuntu server which is in below
I always end up facing trouble installing
php7.x-dev
like thisSo I skip
php7.x-dev
installation and go straight tosudo pecl install redis
then I got new Error:I endup searching for installing
phpize
and the solution is to installphp-dev
.for those of you have similiar problem like me. instead of
sudo apt-get install php7.x-dev
usesudo aptitude install php7.x-dev
Install aptitude
then run
sudo apt-install php7.x-dev
and then if prompt ask if you want to Keep the following packages at their current version:select NO this will auto downgrade or upgrade the version in order to install
php7.x-dev
.Next step install redis:
Then You should add
"extension=redis.so"
to php.ini. in my case php.ini is located in/etc/php/7.3/apache2/php.ini
And restart apache2 by running this command:
if you have not install
php-fpm
run this command.Note: that you need to restart the
php artisan serve
. this because laravel will not recognize PHP Redis even if you are successfully installed package (redis, php-dev) so keep in mind restart the php artisan serve.If you are using Laravel updated version ~8 THEN:
you have to change in 2 files:
File 1:
replace ‘phpredis’ with ‘predis’ in /bootstrap/cache/config.php
File 2:
replace ‘phpredis’ with ‘predis’ in /config/database.php
My problem was solved by that
I upgraded from Laravel 5.2 to Laravel 8.
Old Laravel 5.2 settings were:
Settings for Laravel 8, which are working fine now:
this problem goes out after reboot of the server and nothing more, u don’t need to install or reinstall anything just reboot, that’s the secret matter