In a previous post I’ve talked about installing
phpredis a PHP Extension for Redis that has to be compiled from source. But what if you’re hosting scenario doesn’t allow you to compile extensions? Well you’re in luck, in addition to the extension, there are additional client libraries out there for Redis that are PHP only and a
require away from using!
Currently the most recommended client for PHP according to redis.io. The client is both actively maintained and received a gold star (the same is true about
phpredis). Predis requires PHP version 5.3.2+ and makes use of namespaces. My big gripe with Predis is that if you’re using
__autoload() you will run into issues as Predis has it’s own
__autoload(). Predis is released under the MIT license and has a full test suite (depends on PHPUnit)
Like Predis, Rediska is actively maintained but hasn’t received the gold star of approval. Also like Predis, Rediska can mess up an existing
__autoload() and comes with a full test suite. Rediska boasts integration with both Zend Framework and Symphony and is released under a custom license.
Redisent is actively maintained and is marketed towards the “modest developer”. The client itself is built to be flexible and tolerant to changes to the Redis protocol. Redisent is noticeably smaller than Predis and Rediska will still supporting the same commands. Because all of Redisent’s classes are contained in a single file, there’s no issues with
__autoload() like the aforementioned. Redisent is released under the ISC License and does include a full test suite.
The only client on our list that was not flagged as active on redis.io is Credis. Upon checking the project’s GitHub page, it does seem like Credis does have some activity (mostly through pull requests). Credis is unique in the fact that it can function as a stand alone client but as a wrapper for
phpredis. Come to find out, Credis is actually a fork of Redisent but doesn’t necessarily give a reason why they forked to begin with. Credis seems to be released under either a custom license or the MIT license (you’d think it would need to be under the ISC License though). A test suite is also available.
So which should I pick?
From my own experience, I prefer Predis when I have to use a PHP client and
phpredis when I have the availability to compile it from source. Technically speaking the C library will also perform better than a PHP equivalent for obvious reasons. I have used both Predis and Rediska and both get the job done, I just happen to favor Predis (and have since forgot why I made the switch :P). Hope this helps you with your decision on which client to go with!