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

  1. Setup a Forge Server (PHP 7.3, MySQL 5.7)
  2. Install this repo as a site (or any other laravel setup with just horizon installed)
  3. Add Flare/Sentry/Whatever Credentials to your .env
  4. Start a daemon which is running php artisan horizon
  5. Add php artisan horizon:terminate to the Forge deployment script
  6. Deploy
  7. đŸ’„ 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)
  8. Rename the Redis-Facade to RedisManager (maybe directly on the server)
  9. Restart the daemon from Step 4
  10. Deploy
  11. đŸ’„ The deployment should fail with Class 'Redis' not found (https://flareapp.io/share/wx7K3K7R#F22)
  12. Install php-redis (sudo apt install php-redis)
  13. Deploy
  14. Now everything should work.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 9
  • Comments: 39 (28 by maintainers)

Most upvoted comments

I experienced the same issue with an existing application:

I’m using the predis/predis package, and not the PHP extension, since that was easier to set up. In Laravel 5.x there was no need to set the REDIS_CLIENT because the default value of the database.redis.client was predis, which worked as expected with the predis/predis package. Using the Github comparison tool I changed (without much thinking) the default value from predis to phpredis, and then I never thought to add REDIS_CLIENT=predis to 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 predis or 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=predis in 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-redis extension in order to make the phpredis driver to work.

The default was changed in the skeleton so only new apps should have the new default

It was changed in the framework, too.

https://github.com/laravel/framework/pull/29745/files#r317621260

If someone doesn’t have a redis.client key/value pair in their config, I think it would be breaking because this would now fallback to phpredis.

Isn’t this clear enough? laravel/docs#5388

No that documentation is incorrect. As per this issue the correct php-redis is apt install php-redis not pecl install phpredis.

I just can’t understand how this is a breaking change. Look, in your previous laravel versions the default value of client at config/database.php is predis.

At newst versions the default value changed to phpredis with REDIS_CLIENT env, but your apps should work normally

We’re looking into updating Forge for this to install ext-redis by default btw.

I think the problem is that https://laravel.com/docs/6.x/upgrade#redis-default-client makes some assumptions on the readers knowledge:

The default Redis client has changed from predis to phpredis. In order to keep using predis, ensure the redis.client configuration option is set to predis in your config/database.php configuration file.

One has to know that phpredis is actually https://github.com/phpredis/phpredis which is installed via pecl install redis (i.e. it’s not named phpredis here!) and the extension for packages is called php-redis (similar but yet another way for the same phpredis thing).

Yep you’re 100% correct. My previous comment was not 100% accurate I apologize. The docs actually just say phpredis and 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:

  1. vagrant ssh
  2. sudo apt-get update
  3. sudo apt install php-redis
  4. Go to app/config/database.php and change value from “predis” to “phpredis” for value “REDIS_CLIENT” (not always required)
  5. Go to app/config/app.php and rename Predis to PredisManager under Aliases
  6. sudo service php7.3-fpm restart (replace “7.3” with whatever version of PHP as required - you can check with command “sudo php -v”)

That should be it! Worked for me.

I too solved this issue by running sudo apt install php-redis on 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 as predis.

I had no ‘databse.redis.client’ configured explicitely

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