Clone this wiki locally
Predis is a flexible and feature-complete PHP client library for the Redis key-value store.
We are currently in the process of rewriting the whole wiki with new contents, documentation and tips!
Predis requires PHP >= 5.3 and it is entirely written in PHP so it can be used without the need to build and install a native extension for the interpreter, making it also easier and faster to add new features which is great given how fast the development of Redis proceeds.
- Wide range of Redis versions supported (from 1.2 to 2.8 and unstable) using profiles.
- Clustering via client-side sharding using consistent hashing or custom distributors.
- Smart support for redis-cluster (Redis >= 3.0).
- Support for master-slave replication configurations (write on master, read from slaves).
- Transparent key prefixing for all Redis commands.
- Command pipelining (works on both single and aggregate connections).
- Abstraction for Redis transactions (Redis >= 2.0) supporting CAS operations (Redis >= 2.2).
- Abstraction for Lua scripting (Redis >= 2.6) with automatic switching between
- Abstraction for
HSCAN(Redis >= 2.8) based on PHP iterators.
- Connections to Redis are established lazily by the client upon the first command.
- Support for both TCP/IP and UNIX domain sockets and persistent connections.
- Support for Webdis (both
- Support for custom connection classes for providing different network or protocol backends.
- Flexible system for defining and registering custom sets of supported commands or profiles.
This quick tour gives you a quick introduction on how Predis can be configured and used. [OUTDATED: that page actually refers to Predis v0.6, we are still rewriting the whole wiki!]
Predis can be used as-is with any PHP web framework out there but sometimes it is easier to use ad-hoc extensions that make it blend nicely into their logic and common patterns. What follows is a list of such extensions created and maintained by the community:
- Symfony 2.x with SncRedisBundle by Henrik Westphal.
- Silex with PredisServerProvider by Daniele Alessandri.
- Drupal 7.x with Redis module by Pierre Rineau.
The following modules require the PHP 5.2 backport of Predis 0.6:
- Symfony 1.x with sfRedisPlugin by Benjamin Viellard.
- Yii Framework with rediscache by Gustavo Salomé.
If you want to work on Predis, it is highly recommended that you first run the test suite in order to
check that everything is OK, and report strange behaviours or bugs. When modifying Predis please make
sure that no warnings or notices are emitted by PHP by running the interpreter in your development
environment with the
error_reporting variable set to
E_ALL | E_STRICT.
The recommended way to contribute to Predis is to fork the project on GitHub, create new topic branches on your newly created repository to fix or add features (possibly with tests covering your modifications) and then open a new pull request with a description of the applied changes. Obviously you can use any other Git hosting provider of your preference.
The code for Predis is distributed under the terms of the MIT license.