PhpRedis is a native PHP extension providing classes and methods to talk to Redis, with support for Valkey, KeyDB, Dragonfly, clustering, Sentinel, and sessions.
Overview
The PhpRedis extension exposes a PHP API for communicating with the Redis key-value store and compatible alternatives including Valkey, Dragonfly, and KeyDB. Applications use the Redis class and related types to connect, run commands, and handle errors through RedisException where appropriate.
Connection options cover TCP and TLS hosts, Unix domain sockets, timeouts, authentication, database selection, persistent connections, pooling, and configurable backoff when reconnecting. The extension implements Redis data types and server features such as hashes, lists, sets, sorted sets, HyperLogLog, geospatial commands, streams, pub/sub, transactions, Lua scripting, and cluster or array sharding modes.
PhpRedis can act as a PHP session handler by setting session.save_handler and a structured session.save_path with weights, timeouts, authentication, and prefixes across multiple Redis hosts. Session locking, compression, and read timeouts are configurable through dedicated INI settings. Documentation also describes Redis Sentinel support and testing harnesses for Redis, RedisArray, RedisCluster, and RedisSentinel classes.
Installation is documented separately for building the extension into PHP runtimes that need direct in-process access rather than a pure-PHP client library.
Key features
- Native PHP Redis client
- Cluster and RedisArray support
- Redis Sentinel integration
- PHP session save handler
- TLS and Unix socket connections
- Persistent connections and pooling
- Pub/sub, streams, and scripting
- Valkey and KeyDB compatibility
Use cases
- PHP apps using Redis cache
- Redis-backed PHP sessions
- Clustered Redis clients
- Sentinel-managed failover
- In-process Redis command API