Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Key Value Store

Key Value Store Laravel Package

doctrine/key-value-store

Doctrine Key Value Store provides a lightweight Doctrine-style mapper for NoSQL key-value backends. Use simple @Entity/@Id annotations, schema-less values mapped to objects, and a stripped-down object manager with events. Drivers include Redis, DynamoDB, MongoDB, CouchDB and more.

View on GitHub
Deep Wiki
Context7

Abstraction for Key-Value to Plain Old PHP Object mapping

Frequently asked questions about Key Value Store
Can Doctrine KeyValueStore replace Laravel’s cache() helper for structured data?
Yes, but with trade-offs. KeyValueStore maps objects to key-value backends (Redis, DynamoDB, etc.), unlike Laravel’s cache() which serializes arrays or simple data. Use it for complex objects like user sessions or rate-limiting rules, but expect slightly higher overhead than raw Redis. For simple caching, stick with Laravel’s built-in drivers.
How do I install and configure Doctrine KeyValueStore in Laravel?
Install via Composer: `composer require doctrine/key-value-store`. Register a service provider in `config/app.php` to bind the `EntityManager` to Laravel’s container. Configure your backend (e.g., Redis) in a custom config file. No official Laravel package exists, so manual setup is required—similar to integrating third-party Doctrine libraries.
Does Doctrine KeyValueStore support Laravel’s Eloquent events (e.g., model saving, deleting)?
No, but it provides its own event system (postLoad, postPersist, etc.). You can manually trigger Laravel events by listening to these or using a wrapper library. For example, dispatch `eloquent.saved` after `postPersist` fires. This requires custom glue code but isn’t inherently impossible.
What Laravel versions and PHP versions does Doctrine KeyValueStore support?
The package was last updated in 2019 and may not fully support PHP 8.x (e.g., deprecated `ReflectionClass::newInstanceArgs`). Test thoroughly with your Laravel version (8.x+) and PHP 8.0+. For PHP 8.1+, check for compatibility issues with deprecated features or fork the project if needed.
Which backends are actively maintained and recommended for Laravel?
Redis, DynamoDB, and Azure Tables are the most stable options. Redis integrates seamlessly with Laravel’s caching layer, while DynamoDB is ideal for serverless Laravel apps (e.g., AWS Lambda). Avoid less-tested backends like Cassandra or Riak unless you’re prepared to debug or contribute fixes.
How does Doctrine KeyValueStore handle nested objects or relationships?
It doesn’t support references to other objects or relationships like Eloquent. Nested objects must be embedded directly (e.g., as properties) and serialized automatically. For complex hierarchies, flatten the structure or use a hybrid approach (e.g., store IDs and fetch related objects separately).
Is Doctrine KeyValueStore suitable for production use in Laravel?
Proceed with caution. The package is archived (no updates since 2019) and lacks Laravel-specific features. Use it for non-critical data (e.g., caching, sessions) and monitor for issues. For production, consider forking the project or pairing it with a wrapper library to fill gaps like Laravel event integration.
What are the performance implications compared to raw Redis or DynamoDB clients?
KeyValueStore adds abstraction overhead for object mapping, serialization, and event handling. Raw clients (e.g., `predis/predis` for Redis) will be faster for simple operations. Benchmark your use case—KeyValueStore shines for structured objects but may lag for high-throughput, low-latency needs.
Are there alternatives to Doctrine KeyValueStore for Laravel?
Yes. For caching, use Laravel’s built-in `cache()` helper or `spatie/laravel-cache`. For NoSQL object mapping, consider `spatie/laravel-keyvalue` (Laravel-specific) or `jenssegers/mongodb` (MongoDB). For DynamoDB, use `aws/aws-sdk-php` directly or `spatie/laravel-dynamodb`. Evaluate based on your backend and Laravel integration needs.
How do I test Doctrine KeyValueStore in a Laravel application?
Mock the `EntityManager` in unit tests using Laravel’s service container bindings. For integration tests, use in-memory backends like the Doctrine Cache provider or a local Redis instance. Test edge cases like nested objects, concurrency (e.g., simultaneous writes), and serialization failures. No built-in testing utilities exist, so manual validation is key.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor