framework: [6.0] Redis Breaking Change not documented
- Laravel Version: 6.0.0
- PHP Version: 7.3.9
- Database Driver & Version:
Description:
With https://github.com/laravel/framework/commit/39699b8b782a4d6779c57b78d48d8b10dbe49fef there was introduced a breaking change. This creaking change is not documented anywhere within the upgrade guide.
Steps To Reproduce:
I have prepared a repository containing the code to reproduce this behavior. There is also a thread where i wrote a little bit with @driesvints about this: https://twitter.com/Lukas_Kae/status/1169314825006145536
The repository: https://github.com/LKaemmerling/laravel-6-redis-bc
- Setup a Forge Server (PHP 7.3, MySQL 5.7)
- Install this repo as a site (or any other laravel setup with just horizon installed)
- Add Flare/Sentry/Whatever Credentials to your .env
- Start a daemon which is running
php artisan horizon- Add
php artisan horizon:terminateto the Forge deployment script- Deploy
- đ„ The deployment should fail with
Please remove or rename the Redis facade alias in > your "app" configuration file in order to avoid collision with the PHP Redis extension.(https://flareapp.io/share/317xd17b#F24)- Rename the
Redis-Facade toRedisManager(maybe directly on the server)- Restart the daemon from Step 4
- Deploy
- đ„ The deployment should fail with
Class 'Redis' not found(https://flareapp.io/share/wx7K3K7R#F22)- Install
php-redis(sudo apt install php-redis)- Deploy
- Now everything should work.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 39 (28 by maintainers)
I experienced the same issue with an existing application:
Iâm using the
predis/predispackage, and not the PHP extension, since that was easier to set up. In Laravel 5.x there was no need to set theREDIS_CLIENTbecause the default value of thedatabase.redis.clientwaspredis, which worked as expected with thepredis/predispackage. Using the Github comparison tool I changed (without much thinking) the default value frompredistophpredis, and then I never thought to addREDIS_CLIENT=predisto my .env file.Upon deployment this exception occured, which is quite misleading, because actually I shouldnât remove/rename the alias, but instead change the configuration value to
predisor add the environment variable to my .env.The problem is that this change is not documented in the Upgrade Guide, there should be a notice about this changeâŠ
Set
REDIS_CLIENT=predisin your .env file. Solved the problem I had with horizon for me anyway.@LKaemmerling but this isnât an issue with Laravel. The fact that the default was changed doesnât matter. The problem here is that you need the
ext-redisextension in order to make the phpredis driver to work.It was changed in the framework, too.
https://github.com/laravel/framework/pull/29745/files#r317621260
If someone doesnât have a
redis.clientkey/value pair in their config, I think it would be breaking because this would now fallback to phpredis.No that documentation is incorrect. As per this issue the correct php-redis is
apt install php-redisnotpecl install phpredis.I just canât understand how this is a breaking change. Look, in your previous laravel versions the default value of
clientatconfig/database.phpispredis.At newst versions the default value changed to
phprediswithREDIS_CLIENTenv, but your apps should work normallyWeâre looking into updating Forge for this to install ext-redis by default btw.
Yep youâre 100% correct. My previous comment was not 100% accurate I apologize. The docs actually just say
phpredisand when googled the first result is the github page for the pecl extension. Perhaps that could be cleared up in the docs as an outcome to this issue?@kreitje thank you very much - that worked!
For anyone else wanting to resolve this issue, you may try running these commands to on Homestead to get php-redis working:
That should be it! Worked for me.
I too solved this issue by running
sudo apt install php-redison the server.The problem was once I changed and pushed my code with
phpredis, my application was locked with that error. I suppose you could manually remove the config cache and push with the default aspredis.Iâve seen this also, it happens if you have started with a Laravel version < 5.4.0, at which point the setting didnât existed, and upgraded over the years.
Unless you manually synced the changes over from https://github.com/laravel/laravel or republish the configs, youâre gonna miss out some of the changes over time.
Thatâs also documented in the introduction here: https://laravel.com/docs/6.0/redis#introduction