What Is New in Predis 3
Predis 3 is a major overhaul focused on modern PHP compatibility and Redis protocol support. It drops legacy code and introduces a cleaner architecture.
| Category | Key Changes |
|---|---|
| New Features | Support for Redis 7.x commands, RESP3 protocol, and PHP 8.1+. |
| Improvements | Refactored connection handling, reduced internal complexity. |
| Deprecated | Removed PHP 5.x and 7.x support, dropped old connection classes. |
| Bug Fixes | Various fixes for edge cases in command parsing and responses. |
Why Did Predis Drop Support for Older PHP Versions?
Predis 3 requires PHP 8.1 or later. This move allows the codebase to use modern PHP features like type declarations and enums, which makes the client more robust and maintainable.
In practice, this means you can't run v3 on older systems. If you're stuck on PHP 7.x, you'll need to stay on Predis v1.x or v2.x, which are now in maintenance mode.
What's the Deal with the New RESP3 Protocol?
Predis 3 adds support for the RESP3 protocol, which is the new Redis serialization protocol. This enables more complex data types and better client-server communication compared to the old RESP2.
You get support for new Redis 7.x features that rely on RESP3, like push messages and aggregated map responses. The client handles the protocol negotiation automatically, so you don't need to change your code.
How Has Connection Handling Changed?
The connection layer was completely refactored. Older, specialized connection classes like Predis\Connection\PhpiredisStreamConnection have been removed in favor of a more streamlined approach.
Now, the client uses a single connection interface that's easier to extend and debug. This reduces the internal complexity that had built up over the years.
Are There Any Backward Compatibility Breaks?
Yes, this is a major version for a reason. The minimum PHP version is a hard break. Some internal classes and methods that were previously public have been removed or changed.
If you built custom extensions on top of Predis, you'll likely need to update them. The public API for sending commands remains largely the same, so most application code should work without changes.
FAQ
Can I upgrade from Predis v1 directly to v3?
Yes, but you must first ensure your environment runs PHP 8.1 or higher. Then, update your Composer dependency to "predis/predis": "^3.0". Review the changelog for removed functionality if you used any internal classes.
Does RESP3 support affect performance?
It can improve efficiency for certain data types and enables new features, but the core performance for basic commands remains similar. The protocol is handled transparently by the client.
What happens if my Redis server doesn't support RESP3?
Predis will automatically fall back to using the RESP2 protocol during the handshake, so it remains compatible with older Redis servers.
Are there any new required PHP extensions?
No. Predis 3 still only requires the PHP core extensions. It does not mandate any additional extensions like phpiredis.
Is cluster support different in v3?
The core functionality for Redis Cluster is the same, but the underlying connection management has been modernized as part of the broader refactor.