mathiasgrimm's avatar

Redis with phpredis

From reading the Laravel docs regarding redis, is not clear hot to user phpredis in combination with the Redis Facade. Seems like predis is still required and when installed is seems to no use phpredis. setting the client to phpredis seems to make no difference

0 likes
3 replies
NickVahalik's avatar

It uses Predis. The RedisServiceManager instantiates RedisManager which, based upon the database.redis.driver value, creates either a PredisConnector or a PhpRedisConnector.

Ultimately, you end up talking to a PredisConnector or PredisClusterConnector instance.

The abstract Connection class which PredisConnection extends implements a __call function which passes on the actual commands directly to the Predis\Client instance within the actual Connector.

So basically, you are talking directly to the Predis\Client when using the facade.

mathiasgrimm's avatar

I think my version of laravel (5.3) does not have those classes

NickVahalik's avatar

Ah, well then if you don't have those classes, you might just pull in the predis package and then register a singleton/facade that connects to your Redis instance and makes it available to the application. You can use the config and code from 5.6 as a guide.

Please or to participate in this conversation.