Download the PHP package talleu/php-redis-om without Composer
On this page you can find all versions of the php package talleu/php-redis-om. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download talleu/php-redis-om
More information about talleu/php-redis-om
Files in talleu/php-redis-om
Package php-redis-om
Short Description A PHP object mapper library for Redis
License MIT
Informations about the package php-redis-om
php-redis-om ๐๏ธ
A PHP object mapper for Redis.
An Object Mapper for Redisยฎ, designed to providing an intuitive and familiar interface for PHP developers to interact with Redis.
Features ๐ ๏ธ
- Doctrine-like methods and architecture
- Symfony bundle integration
- Easy integration with existing PHP applications
- High performance and scalability with Redisยฎ
- Support for Redis JSON module
- Automatic schema generation
- Search and query capabilities with range filters
- Auto-expiration of your objects
- PHP enum support (backed enums)
- Identity map and dirty tracking with partial updates
- Atomic transactions (MULTI/EXEC)
- Unique constraints (single-field and composite)
- Pagination with total count
- Memory-efficient streaming of large collections
- Bulk delete and update without loading objects into memory
- GEO queries (radius search)
- Pipeline batch reads
- API Platform support (beta)
Requirements โ๏ธ
- PHP 8.2 or higher
- Redis 4.0 or higher
- Redisearch module (available by default with Redis >8 or in redis-stack distribution) (installation)
- php-redis extension OR Predis library
- Redis JSON module (optional, include in redis-stack)
- Composer
Supported types โ
- scalar (string, int, float, bool, double)
- PHP backed enums (string and int)
- timestamp
- json
- null
- DateTimeImmutable
- DateTime
- array and nested arrays
- object and nested objects
- stdClass
Installation ๐
Install the library via Composer:
Depending on your configuration, use phpredis or Predis
Symfony bundle ๐ต
In a Symfony application, you may need to add this line to config/bundles.php
And that's it, your installation is complete ! ๐
API Platform support ๐ท๏ธ
For API Platform users, a basic implementation is provided here: API Platfom X Redis
Basic Usage ๐ฏ
Add the RedisOm attribute to your class to map it to a Redis schema:
After add the RedisOm attribute to your class,
you have to run the following command to create the Redis schema for your classes (default path is ./src):
For Symfony users:
For others PHP applications:
Then you can use the ObjectManager to persist your objects from Redis ! ๐ช
For Symfony users, just inject the RedisObjectManagerInterface in the constructor:
For others PHP applications:
๐ฅณ Congratulations, your PHP object is now registered in Redis !
You can now retrieve your user wherever you like using the repository provided by the Object Manager (or the object manager directly):
Enum Support ๐ท๏ธ
PHP backed enums are natively supported:
Search by enum value:
Range Queries ๐ข
Use MongoDB-style operators for numeric range searches:
Supported operators: $gte (>=), $gt (>), $lte (<=), $lt (<).
Note: Range queries work automatically with HASH format (NUMERIC index is auto-generated for int/float). For JSON format, you must explicitly declare a NUMERIC index:
#[Property(index: ['age' => 'NUMERIC'])].
Pagination ๐
Partial Updates (Merge) โก
Instead of re-persisting the entire object, use merge() to only update changed fields:
For new objects (not loaded via find()), merge() falls back to a full persist().
Batch Reads (Pipeline) ๐
Load multiple objects by ID in a single Redis pipeline call:
GEO Queries ๐
Search objects within a geographic radius (requires a GEO-indexed property):
Unique Constraints ๐
Enforce uniqueness on one or more fields using #[Unique].
Single field:
Composite (combination of fields must be unique):
flush() throws UniqueConstraintViolationException on conflict. Violations within the same flush() call are detected before hitting Redis. Concurrent writes are protected via Redis WATCH/MULTI/EXEC.
Bulk Operations โก
Delete or update large numbers of objects without loading them into PHP memory.
bulkUpdate() throws BulkOperationException when $changes targets a #[Unique] field. Use stream() + merge() + flush() instead for those cases.
Streaming Large Collections ๐
findAll() loads everything into memory. stream() fetches objects in batches and yields them one by one, keeping memory bounded regardless of collection size.
Advanced documentation ๐
All versions of php-redis-om with dependencies
ext-json Version *