- How do I install dunglas/doctrine-json-odm in a Laravel application?
- Run composer require dunglas/doctrine-json-odm, then wire Doctrine into Laravel using an integration such as fruitcake/laravel-doctrine. If you use Symfony Serializer for denormalization, configure that bridge as well. Symfony and API Platform users usually need no extra bootstrap, but Laravel requires manual Doctrine and serializer integration.
- Does dunglas/doctrine-json-odm support Laravel?
- It is not Laravel-native but can be used in Laravel through Doctrine ORM integration such as fruitcake/laravel-doctrine. You must also wire Symfony Serializer if you rely on JSON document denormalization. Laravel compatibility therefore depends on the Doctrine bridge, PHP version, and Symfony component constraints rather than a Laravel-specific package release.
- Which databases are supported by Doctrine JSON ODM?
- It supports PostgreSQL JSON and JSONB columns from PostgreSQL 9.4 and MySQL JSON columns from MySQL 5.7.8. PostgreSQL is preferred for JSON-heavy workloads because jsonb operators and GIN indexes provide strong querying and indexing. MySQL and SQLite use more generic JSON handling and do not get equivalent jsonb-specific benefits.
- What is the difference between JsonDocumentType and JsonbDocumentType?
- JsonDocumentType maps documents to a generic JSON column, while JsonbDocumentType targets PostgreSQL jsonb columns. Use JsonbDocumentType when you need PostgreSQL jsonb operators and indexes. MySQL should use the JSON column type rather than PostgreSQL jsonb-specific behavior.
- Does v1.5.1 introduce breaking changes or a database migration?
- No, v1.5.1 is a patch release with no breaking changes, deprecations, new schema requirements, or DBAL/Doctrine migration changes indicated. It fixes denormalization of typed object collections as Foo[][] with Symfony Serializer 8.1. It is a low-risk upgrade, especially if you use nested typed collections. Pin to 1.5.1 or higher and add a regression test if applicable.
- How do I use PostgreSQL jsonb operators and GIN indexes with this package?
- Store documents in jsonb columns via JsonbDocumentType and add GIN indexes through Doctrine migrations or native SQL. Query with PostgreSQL jsonb operators using native SQL or DB-specific query builders. The ODM handles document mapping, but index and query design remain database-specific.
- What PHP and Doctrine versions are required for v1.5.1?
- Existing requirements remain unchanged in v1.5.1, including PHP 8.1+ and Doctrine DBAL/ORM compatibility considerations such as DBAL 4.3.0+ and ORM 3.0+. Confirm exact Composer constraints for your project before upgrading. The patch does not add a new DBAL or ORM migration step.
- How should I validate JSON documents stored with Doctrine JSON ODM?
- Enforce structure with database constraints, Symfony Validator or JSON Schema, and application-level checks. JSON columns are schema-less, so without validation you risk data drift. Cache validation results where runtime overhead matters.
- Is Doctrine JSON ODM safe for production use in a Laravel app?
- It can be production-safe if you enforce validation, define appropriate indexes, and test DBAL/ORM upgrades. PostgreSQL jsonb workloads gain the most because of path queries and GIN indexes, while MySQL and SQLite need more generic JSON handling. Keep PostgreSQL-specific query logic behind interfaces or feature flags if portability matters.
- What are alternatives to dunglas/doctrine-json-odm?
- Alternatives include Doctrine MongoDB ODM for a dedicated document database, native PostgreSQL jsonb columns with custom Doctrine DBAL types, or manual relational modeling with JSON columns. Doctrine JSON ODM is useful when you want document-style storage inside Doctrine ORM and an RDBMS. Choose based on whether you need PostgreSQL JSON indexing, a full document store, or simpler relational schemas.