Download the PHP package alephtools/ddd without Composer
On this page you can find all versions of the php package alephtools/ddd. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alephtools/ddd
More information about alephtools/ddd
Files in alephtools/ddd
Package ddd
Short Description Helpful instruments for Domain Driven Design.
License MIT
Informations about the package ddd
DDD Tools
Collection of classes that can be useful to build applications according to Domain Driven Design (DDD).
Table of Contents
- Infrastructure Layers
- Base Domain Classes
- DTO
- DomainObject
- ValueObject
- Enums
- Helpers
- SQL Builder
- MySQL
- Select Queries
- PostgreSQL
- MySQL
- Base Domain Classes
- Model Layer
- Entity Identities
- Common Value Objects
- Common Domain Exceptions
- Common Domain Events
- Application Layers
- Base Application Service
- Base Query Service
- Domain Event Subscribers
Base Domain Classes
DTO
The base class of all domain objects is DTO
. DTO allows to embed properties (as in JAVA, C# and some other
strictly-typed program languages) in our classes. A class property consists of three elements:
- Private or protected class field.
- Property description according to PHPDoc (@property) at the class comment.
- Optional setter or getter.
DTO
is an abstract class. There are two child classes of it: StrictDto
and WeakDto
. The difference between them is
that the first one throws NonExistentPropertyException
during class initialization if a property does not exist and
the second one isn't.
DTO usage example:
There are some rules to get properties work properly:
- The property type in PHPDoc comment does not matter. To restrict property by type you need to specify type hinting for
property setter, getter or field. If assigned value does not match property type
InvalidArgumentException
is thrown. - Getters of read-only or regular properties must be public.
- Setters of write-only or regular properties must be public.
- Private and protected setters are automatically invoked during the class initialization.
- If you want to inherit a property its field and setter must not be private.
DomainObject
DomainObject
is a base class for all domain object. It is inherited from StrictDto
. All domain objects contains sone
useful methods:
equals()
to compare domain objects with others.copy()
to create a copy of the domain object.copyWith()
to create a copy of the domain object with the given property values.hash()
to get unique domain object hash.domainName()
to get name of the domain object (it equals class name by default).
ValueObject
ValueObject
is a base class for all domain value objects. It has the same methods as DomainObject
.
SQL Builder
SQL Builder is a simple wrapper that allows to build SQL query string for some particular RDBMS (MySQL and PostgreSQL are currently only supported). You can use it to be independent of any PHP framework. See the table below to figure out how to use SQL Builder.
MySQL
Select Queries
PHP Expression:
Executed SQL Query:
PHP Expression:
Executed SQL Query:
PHP Expression:
Executed SQL Query:
PHP Expression:
Executed SQL Query:
PHP Expression:
Executed SQL Query:
PHP Expression:
Executed SQL Query:
PHP Expression:
Executed SQL Query:
PostgreSQL
All versions of ddd with dependencies
ext-json Version *
ext-bcmath Version *
ext-mbstring Version *