Domain Driven Design in PHP with libdomain
Lately, I've been utilizing domain driven design in newer projects and features. I've found myself writing a lot of boiler-plate code and decided to create a library to cut down on repeat code.
Libdomain can be used to do a lot of grunt work with setting up PHP objects to act as entities, collections, and value objects.
An entity class that utilizes an immutable value object would look something like this with libdomain:
libdomain_example.php
Other domain managers
Some ORMs come with their own form of entity, but not all. In many cases, an application uses multiple data-stores that may not all be supported by the ORM of choice. This is the opportunity to use a unified entity interface to support domain logic.
Unify
Libdomain is designed in such a way that the base abstract classes (Entity, Collection, CollectionEntity, and ValueObject) are not required to be extended to get their benefits. You can implement their interfaces and hook in the traits that cover the interface implementation. This means the entities created by the ORM of choice can be adapted and unify under a common interface.













