andrzejkupczyk/ddd-generic-subdomain

Interfaces supporting coherent implementation of DDD components

dev-master / 1.0.x-dev 2021-02-14 10:16 UTC

This package is auto-updated.

Last update: 2024-04-14 16:50:29 UTC


README

PHP requirement

This package provides interfaces that can be used to support coherent implementation of DDD components within your core domain. It is intended to be used as an off-the-shelf solution that helps to avoid clogging up a domain model and to force members of your team or yourself on thinking in terms of immutable objects and their interaction.

All implementations are inspired by literature, ValueObject library created by Nicolò Pignatelli, SeedStack Java development stack, ValueObjects toolkit and some other, more direct sources, but mainly by my experiences and needs.

Components

Documentation is for the weak, but there is some useful information in the code.

Value Object's Immutability

The ValueObject interface represents an immutable object that have no identity, however immutability is not guaranteed in PHP. Currently, the only way of achieving immutability is through encapsulation, therefore you can use ImmutableValueObject proxy class.

$year = new ImmutableValueObject(new Year(2020));
// or, using a helper function
$year = immutable(new Year(2020));

A proxied value object acts as a substitute for a real one, but at the same time it gives more confidence regarding its immutability.

Finally, you can also use Psalm.

Installation

Using Composer:

composer require andrzejkupczyk/ddd-generic-subdomain

Example usages

https://github.com/andrzejkupczyk/ddd-building-blocks