dunglas/doctrine-json-odm
Doctrine JSON ODM maps JSON documents to PHP objects using Doctrine-style metadata, enabling persistence and querying of JSON data through a familiar ORM-like API. Useful for working with JSON stored in files or other backends while keeping domain models clean.
Use Case Alignment:
jsonb_document type (DBAL 4.3.0+) introduces PostgreSQL-specific optimizations (e.g., jsonb path queries, GIN indexes), ideal for:
WHERE jsonb_column @> '{"key": "value"}').jsonb vs. generic JSON).Paradigm Shift:
jsonb_document is PostgreSQL-exclusive, limiting portability to MySQL/SQLite.@Assert\Json) must be explicitly implemented to avoid data drift.Doctrine Ecosystem Synergy:
fruitcake/laravel-doctrine).Core Compatibility:
doctrine/dbal and doctrine/orm via Composer.jsonb_document leverages native jsonb optimizations (e.g., indexing, operators like @>).jsonb_document; fall back to generic JsonType.@Assert\Json) to enforce structure.ORM Overhead:
jsonb_document may reduce overhead for PostgreSQL by using native jsonb serialization.->>, @>) remain potentially slower than indexed columns; benchmark with EXPLAIN ANALYZE.Tooling:
[ORM\Column(type: JsonType::class)]) and messenger components for async JSON processing.| Risk Area | Mitigation Strategy |
|---|---|
| PostgreSQL Lock-in | jsonb_document is PostgreSQL-only. Mitigate by: |
JsonStorageInterface).jsonb_document vs. generic JsonType. |
| DBAL Migration | Updating to DBAL 4.3.0+ may break migrations. Test with:doctrine/dbal’s schema tool (SchemaTool::createSchema).symfony/validator) via Composer.@>) won’t work in MySQL. Use:JsonType::postgresJsonbPath()).CHECK).jsonb operators, GIN indexes)?jsonb_column->'$.nested.key')?CHECK)?fruitcake/laravel-doctrine, custom Doctrine service providers).jsonb_document (optimized jsonb support).JsonType; no jsonb_document benefits.tags array changes).spatie/laravel-data) for JSON fields.webonyx/graphql-php) for JSON type mapping.jsonb_document with a PostgreSQL-only entity (e.g., UserPreferences).EXPLAIN ANALYZE for JSON path queries).composer.json for DBAL 4.3.0+ and test migrations.JsonType with jsonb_document for PostgreSQL tables.JsonType for MySQL).jsonb_document format.doctrine/dbal (≥4.3.0), doctrine/orm (≥3.0).symfony/validator (for JSON schema validation).symfony/messenger (for async JSON processing).fruitcake/laravel-doctrine (for Laravel integration).pdo_pgsql: Required for jsonb_document (PostgreSQL-specific).json: Native extension (enabled by default).How can I help you explore Laravel packages today?