somnambulist / domain
Provides a collection of entities, helpers and base implementations for creating domain objects.
Installs: 4 776
Dependents: 8
Suggesters: 0
Security: 0
Stars: 27
Watchers: 6
Forks: 2
Open Issues: 0
Requires
- php: >=8.1
- ext-bcmath: *
- ext-json: *
- ext-mbstring: *
- beberlei/assert: ^3.3
- pragmarx/ia-str: ^7.3
- ramsey/uuid: ^4.7
- somnambulist/collection: ^5.3
- somnambulist/enumeration: ^1.0
Requires (Dev)
- ext-pdo: *
- doctrine/doctrine-bundle: ^2.11.0
- doctrine/orm: ^3.0
- pagerfanta/pagerfanta: ^3.8
- phpspec/prophecy-phpunit: ^2.1
- phpunit/phpunit: ^10.5
- somnambulist/read-models: ^3.3
- symfony/amqp-messenger: ^6.4
- symfony/event-dispatcher: ^6.4
- symfony/framework-bundle: ^6.4
- symfony/http-foundation: ^6.4
- symfony/messenger: ^6.4
- symfony/phpunit-bridge: ^6.4
- symfony/property-access: ^6.4
- symfony/security-bundle: ^6.4
- symfony/serializer: ^6.4
- symfony/var-dumper: ^6.4
- symfony/yaml: ^6.4
Suggests
- doctrine/orm: To use the Doctrine components and have an entity mapper
- giggsey/libphonenumber-for-php: To validate phone numbers / convert to E164 from a local format
- laravel-doctrine/orm: A Laravel mapping for Doctrine
- pagerfanta/pagerfanta: For Pagination of Doctrine results and other data
- symfony/http-foundation: For request id injection into event context
- symfony/messenger: (A)Sync Bus implementation for Symfony needed for query/command/event bus messenger implementations
- symfony/property-access: Needed for serializing JSON payloads
- symfony/security-core: For injecting the user information into event context
- symfony/serializer: Send domain events as JSON strings via messenger
- dev-master
- 6.0.0
- 5.x-dev
- 5.1.0
- 5.0.0
- 4.7.0
- 4.6.0
- 4.5.0
- 4.4.0
- 4.3.4
- 4.3.3
- 4.3.2
- 4.3.1
- 4.3.0
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.0
- 4.0.0
- 3.2.0
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.0
- 2.5.1
- 2.5.0
- 2.4.5
- 2.4.4
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.0
- 2.2.8
- 2.2.7
- 2.2.6
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-10-31 00:21:49 UTC
README
Provides a core set of support classes for building domain oriented projects. This library compiles the previously separate domain and mapping libraries into a single project for easier maintenance.
It consists of:
- Commands
- CommandBus interface / abstract command
- SF Messenger implementation
- Doctrine
- Enumeration factories + Type bindings
- Additional types / type overrides for the Doctrine Type system
- Abstract EntityLocator that extends EntityRepository
- Custom Postgres DQL functions
- Custom traits for EntityRepository
- Models
- Contracts - value object interface definitions
- Types - a collection of value-objects, enumerations, and date helpers
- AggregateRoot - an aggregate root stub implementation that can raise events
- AbstractEntity and AbstractEntityCollection - child entities and helper for an aggregate root
- Events
- EventBus interface / abstract event
- SF Messenger EventBus implementation
- Doctrine subscriber that broadcasts onFlush all events from aggregate roots
- Custom serializer to handle encode/decode when the event class does not exist
- Jobs
- JobQueue interface / abstract job
- SF Messenger implementation
- Queries
- QueryBus interface / abstract query
- SF Messenger implementation
- default XML mappings for embeddable objects in Doctrine .dcm.xml and Symfony .orm.xml conventions
Requirements
- PHP 8.1+
- mb_string
- bcmath
- beberlei/assert
- eloquent/enumeration
- somnambulist/collection
- symfony/messenger for the Messenger bus implementations.
Installation
Install using composer, or checkout / pull the files from github.com.
- composer require somnambulist/domain
Upgrading from 4.X to 5.X
From 5.X this project will be re-namespaced to drop Domain
. 4.X includes a classmap.php
providing
aliases for backwards compatibility.
From 5.0 the QueryBus supports typed response objects. This is an optional feature that provides a built-in mechanism to handle failed queries without trapping exceptions in the calling code.
From 5.0 domain event names are always generated at construction time as snake_case
.
Upgrading from 3.X to 4.X
From 4.X this project was re-namespaced to Somnambulist\Components\Domain
. Update all references to
reflect this change this includes any Doctrine mapping files / annotations.
The Doctrine AbstractIdentityType
was moved out of the Identity
namespace to the main Types
.
Usage
See the docs folder for more documentation on each component.
- Aggregate Root
- Domain Events
- Value Objects
- Enumerations
- Enumeration Bridge
- Doctrine Mapping
- Symfony Messenger Integration
- Using Command Query Separation