Download the PHP package goodwix/doctrine-json-odm without Composer
On this page you can find all versions of the php package goodwix/doctrine-json-odm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package doctrine-json-odm
Doctrine JSON ODM library
Inspired by https://github.com/dunglas/doctrine-json-odm
This is beta version of library. Main differences from Dunglas library:
- library does not store any metadata in json field;
- doctrine ODM type uses main Symfony serializer service (so you can easily extend serialization process by adding normalizers/denormalizers globally in dependency injection config);
- automatic registration of ODM types for Doctrine (using Symfony autowiring and autoconfigure features).
Features
- Object-Document Mapping with database json types
- Doctrine 2.5+ support
- PostgreSQL 9.4+ support
- Symfony 5+ support (not tested with previous versions)
- MySQL support not tested
Additional features
- Automatic registering normalizers for use with Java-like collections from ramsey/collection library
Install
Install with Symfony 4
To install the library, use Composer.
Add lines to config/bundles.php
(no automatic configuration is available for beta version).
Create package config file config/packages/doctrine-json-odm.yaml
with next content.
there src/ODM
is the root path for your ODM entities (like src/Entity
for Doctrine).
Usage
Basic usage with automatic ODM types registration
Create entity class for ODM type in ODM-specific directory (like src/ODM
) and mark it with \Goodwix\DoctrineJsonOdm\Annotation\ODM
annotation.
Create doctrine entity class with field type App\ODM\Document
.
Now you can easily manage your ORM entity with ODM class field
Manual usage with Doctrine and Symfony Serializer component
To manually register Doctrine ODM types use ODMType::registerODMType()
method.
Examples with Symfony application
You can see example of Symfony 4 application with using ODM library in this directory.
Deal with abstract
As an abstract
class could not be created as an instance, each concrete children have to be mapped into the abstract class.
Indeed, the Symfony Serializer
must know the real type in this case through a discriminator field to determine the real object behind
the stored data. For that, it use Symfony\Component\Serializer\Annotation\DiscriminatorMap
. More info is available [here](
Maybe this way : Symfony serializer : discriminator
For example, if we have an abstract and 2 children
Contribution
You can run composer lint
before pushing to repository to ensure that there are no code style errors.
Please remember to add some tests if you change library code.
All versions of doctrine-json-odm with dependencies
ext-json Version *
doctrine/orm Version ^2.5
symfony/property-access Version ^4.4|^5.3|^6.0
symfony/property-info Version ^4.4|^5.3|^6.0
symfony/serializer Version ^4.4|^5.3|^6.0