Predis
A flexible, pure-PHP Redis and Valkey client with clustering and replication support
Repository Health
Technical Analysis
Predis is a feature-complete Redis (and Valkey) client for PHP that requires no C extension — it implements the full RESP protocol in pure PHP, so it can be installed with just Composer on any host, including shared or restricted environments where compiling phpredis isn’t an option. It supports every Redis command surface from version 3.0 through 8.0, plus abstractions for transactions (MULTI/EXEC), Lua scripting with automatic EVALSHA/EVAL fallback, pipelining, and cursor-based iterators for SCAN/SSCAN/ZSCAN/HSCAN.
Beyond single-node connections, Predis has built-in support for client-side sharded clusters, Redis Cluster, master-replica replication topologies, and Redis Sentinel for automatic failover discovery. Connections are established lazily and can be TCP, TLS-encrypted, UNIX sockets, or persistent, and the library exposes a pluggable connection-factory and command-factory system so custom protocol or command behavior can be layered in without forking the library.
What You Get
- A
Predis\Clientclass supporting Redis 3.0 through 8.0 commands via named-array or URI-string connection parameters - Aggregate connections for client-side sharded clusters, Redis Cluster, master-replica replication, and Sentinel-based failover
- Abstractions for MULTI/EXEC transactions, CAS operations, and Lua scripting with automatic EVALSHA/EVAL switching
- Command pipelining and PHP-iterator-based cursors for SCAN/SSCAN/ZSCAN/HSCAN
- TCP, TLS/SSL, UNIX-socket, and persistent connection support, plus transparent key-prefixing
Common Use Cases
- Adding Redis-backed caching, sessions, or queues to a PHP application on hosts where the phpredis C extension can’t be installed
- Connecting to a Redis Cluster or Sentinel-managed replica set from PHP with automatic node/failover discovery
- Running Lua scripts against Redis for atomic multi-key operations without needing raw EVAL/EVALSHA bookkeeping
- Building multi-tenant PHP applications that need transparent key-prefixing to isolate tenants sharing one Redis instance
Under The Hood
Architecture - src/Client.php is the central entry point, delegating command execution to a connection resolved via src/Connection/ (single-node, cluster, or replication aggregates under src/Cluster/ and src/Replication/); src/Command/ implements each Redis command as its own class through a command factory, src/Protocol/ implements the RESP wire protocol parser/serializer, and src/Transaction/, src/Pipeline/, and src/Monitor/ layer transaction, pipelining, and MONITOR support on top of the same connection abstraction. src/Configuration/ implements the options container that wires together connection factories, cluster/replication backends, and command factories at client construction time. Tech Stack - Pure PHP 7.2/8.x with no required C extension; the only hard dependency is psr/http-message, with an optional suggestion for the relay PECL extension for faster in-memory caching. Dev tooling includes PHPStan for static analysis and PHP-CS-Fixer for style enforcement. Code Quality - The tests/ directory contains 561 PHP test files (PHPUnit) covering individual command classes, each connection backend, cluster/replication aggregation logic, and protocol edge cases — one of the most thoroughly tested PHP Redis clients available. The project has 2,734 total commits across 63 tagged releases and averages 10+ commits/month, reflecting sustained active maintenance under lead maintainer Till Krüss. API Design - The client API mirrors Redis command names directly ($client->set(), $client->get(), $client->zadd()), so developers familiar with redis-cli find the PHP surface immediately recognizable; connection and cluster/replication configuration is handled via a single options array passed to the constructor, keeping the common case (a single new Predis\Client() call) simple while still exposing advanced configuration for clustering and custom backends.
Used by 7 apps in this directory
Bagisto
Analytics · Ecommerce
Open-source Laravel eCommerce platform for building multi-vendor marketplaces, B2B stores, headless commerce, and AI-powered storefronts.
Crater
Invoicing Finance
Open source invoicing and billing platform for freelancers and small businesses — create estimates, track expenses, accept Stripe payments, and run recurring invoices from your own server.
Fleetbase
Logistics
Modular open-source logistics and supply chain operating system
Invoice Ninja
Invoicing Finance · Project Management
Self-hostable invoicing, time-tracking, and multi-gateway payment platform for freelancers and small businesses, with built-in e-invoicing compliance for EU and global standards.
Mautic
Automation · Marketing · Ecommerce
The world's largest open source marketing automation platform — own your data, run multi-channel campaigns, and escape vendor lock-in forever.
Pixelfed
Social Media
A decentralized, self-hosted photo sharing platform built on ActivityPub for the open Fediverse.
wallabag
Bookmarks Archiving
Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.