chgst / persistence-doctrine
Doctrine implementation for data store
0.3.0
2023-10-08 17:00 UTC
Requires
- chgst/common: ^0.3.1
- doctrine/persistence: ^3.2.0
Requires (Dev)
- dg/bypass-finals: ^1.5
- doctrine/mongodb-odm: ^2.5.2
- doctrine/orm: ^2.16.2
- friends-of-phpspec/phpspec-code-coverage: ^v6.3.0
- php-coveralls/php-coveralls: ^v2.6.0
- phpspec/phpspec: ^7.4.0
This package is auto-updated.
Last update: 2024-11-08 19:08:14 UTC
README
Installation
composer require chgst/persistence-doctrine
Configuration
Create your model class:
<?php // src/Document/DefaultEvent.php namespace Document; use Chgst\Event\Event; class DefaultEvent extends Event { protected string $id; public function getId(): string { return $this->id; } public function setId(string $id): self { $this->id = $id; return $this; } }
Add mapping
<doctrine-mongo-mapping xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping https://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd"> <document name="Document\Event"> <id /> <field field-name="name" type="string" nullable="false" /> <field field-name="aggregateType" type="string" nullable="false" /> <field field-name="aggregateId" type="string" nullable="false" /> <field field-name="payload" type="hash" nullable="false" /> <field field-name="createdAt" type="date" nullable="false" /> <field field-name="createdBy" type="string" nullable="false" /> </document> </doctrine-mongo-mapping>