dontdrinkandroot/doctrine-key-value-storage-bundle
int, string, bool).EntityManager, Connection), reducing boilerplate for CRUD operations.laravel-doctrine/orm) can integrate this bundle with minimal friction.v2.10+), which Laravel can support via doctrine/dbal and doctrine/orm.key_value_store) with columns for key, value, type, and optional metadata.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Bundle Maturity | Low Stars/Dependents: Unproven in production; minimal community adoption. | Evaluate via proof-of-concept (PoC) with a non-critical feature. |
| Performance | No benchmarks, but Doctrine overhead may impact high-frequency writes. | Test with realistic workloads (e.g., 10K writes/sec) before full adoption. |
| Type Safety | Relies on Doctrine’s type mapping (e.g., json for complex types). |
Validate edge cases (e.g., serialization of custom objects). |
| Concurrency | No explicit locking mechanisms for key collisions. | Use optimistic locking (Doctrine @Version) or external locks (e.g., Redis). |
| Debugging | Limited tooling (e.g., no Doctrine Profiler integration). | Instrument with custom logging or extend Doctrine’s event system. |
user:123:preferences)?database driver) or Eloquent accessors suffice?KeyValue table) that’s simpler?serialize columns).composer require dontdrinkandroot/doctrine-key-value-storage-bundle
config/packages/doctrine_key_value_storage.yaml:
doctrine_key_value_storage:
table_name: 'key_value_store'
columns:
key: 'string'
value: 'text'
type: 'string'
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
class Version20230101000000 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE key_value_store (
id INT AUTO_INCREMENT PRIMARY KEY,
key VARCHAR(255) NOT NULL,
value TEXT NOT NULL,
type ENUM("string", "int", "bool", "json") NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY unique_key (key)
)');
}
}
jsonb vs. MySQL’s json).KeyValueStore::get('key') vs. Redis::get('key')).KeyValueService):
class KeyValueService {
public function __construct(private EntityManager $em) {}
public function get(string $key, string $type = 'string'): mixed {
$repo = $this->em->getRepository(KeyValue::class);
$item = $repo->findOneBy(['key' => $key]);
return $item ? $item->getValue($type) : null;
}
}
KeyValue entity and EntityManager.config or environment variables to toggle the new store.key_value_store.query_time (slow queries).key_value_store.write_latency (insert/update delays).key_value_store.table_size (growth trends).How can I help you explore Laravel packages today?