All Projects → biberlabs → Ddd Embeddables

biberlabs / Ddd Embeddables

Licence: mit
A collection of reusable value objects written in PHP and targeting versions 5.6 and above.

Projects that are alternatives of or similar to Ddd Embeddables

Isis
Apache Isis™ software is a framework for rapidly developing domain-driven apps in Java. Write your business logic in entities, domain services or view models, and the framework dynamically generates a representation of that domain model as a webapp or as a RESTful API. For prototyping or production.
Stars: ✭ 605 (+816.67%)
Mutual labels:  domain-driven-design
Factory
The missing, complete example of Domain-Driven Design enterprise application backed by Spring stack
Stars: ✭ 967 (+1365.15%)
Mutual labels:  domain-driven-design
Sink
Minimal programming language for embedding small scripts in larger programs
Stars: ✭ 42 (-36.36%)
Mutual labels:  embeddable
Komga
Media server for comics/mangas/BDs with API and OPDS support
Stars: ✭ 647 (+880.3%)
Mutual labels:  domain-driven-design
Rails event store
A Ruby implementation of an Event Store based on Active Record
Stars: ✭ 947 (+1334.85%)
Mutual labels:  domain-driven-design
Kopf
A Python framework to write Kubernetes operators in just few lines of code.
Stars: ✭ 971 (+1371.21%)
Mutual labels:  domain-driven-design
Cp Ddd Framework
A lightweight flexible development framework for complex business architecture with full ecosystem!轻量级业务中台开发框架,中台架构的顶层设计和完整解决方案!
Stars: ✭ 566 (+757.58%)
Mutual labels:  domain-driven-design
Gamecomposer
GameComposer is a game authoring tool and also a game runtime environment targeting at desktop and mobile devices.
Stars: ✭ 59 (-10.61%)
Mutual labels:  domain-driven-design
Eventhorizon
CQRS/ES toolkit for Go
Stars: ✭ 961 (+1356.06%)
Mutual labels:  domain-driven-design
Asombroso Ddd
Una lista cuidadosamente curada de recursos sobre Domain Driven Design, Eventos, Event Sourcing, Command Query Responsibility Segregation (CQRS).
Stars: ✭ 41 (-37.88%)
Mutual labels:  domain-driven-design
Eventsourcing
A library for event sourcing in Python.
Stars: ✭ 760 (+1051.52%)
Mutual labels:  domain-driven-design
Happysocialmedia
Microservices Social Media / Network / Chatt, with .net core 2.2, Docker, Implement with Domain Driven Design with all best practices design and architetural patterns as DDD, CrossCutting IoC, SOLID, etc
Stars: ✭ 28 (-57.58%)
Mutual labels:  domain-driven-design
Ddd Dynamic
Domain Driven Design in Python, Ruby and other dynamic languages resources
Stars: ✭ 973 (+1374.24%)
Mutual labels:  domain-driven-design
Practical.cleanarchitecture
Asp.Net Core 5 Clean Architecture (Microservices, Modular Monolith, Monolith) samples (+Blazor, Angular 11, React 17, Vue 2.6), Domain-Driven Design, CQRS, Event Sourcing, SOLID, Asp.Net Core Identity Custom Storage, Identity Server 4 Admin UI, Entity Framework Core, Selenium E2E Testing, SignalR Notification, Hangfire Tasks Scheduling, Health Checks, Security Headers, ...
Stars: ✭ 639 (+868.18%)
Mutual labels:  domain-driven-design
Base
https://www.researchgate.net/profile/Rajah_Iyer
Stars: ✭ 48 (-27.27%)
Mutual labels:  domain-driven-design
White Label
A Vinyl-Trading enterprise app built with Node.js + TypeScript using Domain-Driven Design
Stars: ✭ 591 (+795.45%)
Mutual labels:  domain-driven-design
Foxoffice
Sample application demonstrating how to build a distributed cloud .NET Core application based on CQRS and Event Sourcing.
Stars: ✭ 33 (-50%)
Mutual labels:  domain-driven-design
Context Mapper Examples
ContextMapper DSL: Examples
Stars: ✭ 66 (+0%)
Mutual labels:  domain-driven-design
Lily
This repository has moved: https://gitlab.com/FascinatedBox/lily
Stars: ✭ 1,081 (+1537.88%)
Mutual labels:  embeddable
Jdonframework
Domain-Driven-Design Pub/Sub Domain-Events framework
Stars: ✭ 978 (+1381.82%)
Mutual labels:  domain-driven-design

DDD Embeddables


Build Status Scrutinizer Code Quality Code Coverage

A collection of reusable value objects written in PHP and targeting versions 5.6 and above. Value objects are essential building blocks of Domain Driven Design approach and described by Martin Fowler in P of EAA page 486 as below:

"Value object is a small simple object, like money or a date range, whose equality isn't based on identity."

– Martin Fowler

All classes in this library annotated as ORM\Embeddable with appropriately adjusted column attributes. This makes them ready to use in any project with Doctrine ORM as Embeddables.

Installation & Usage

Install the library using composer.

$ composer require biberlabs/ddd-embeddables

and use it in your entities:

<?php

namespace MyApp\Entity;

use Doctrine\ORM\Mapping as ORM;
use DDD\Embeddable\EmailAddress;

/**
 * @ORM\Entity
 */
class User {

    /**
     * @ORM\Embedded(class="DDD\Embeddable\EmailAddress")
     */
    private $email;

    // Returns an EmailAddress instance, not a string
    public function getEmail();

    // Use type-hinting if you need a setter
    public function setEmail(EmailAddress $email);
}

Afterwards, you can write custom DQL queries based on your requirements while accessing properties of the value objects such as:

SELECT u FROM User u WHERE u.email = :email
-- OR
SELECT p FROM Payments p WHERE p.total.currency = :currency
SELECT p FROM Payments p WHERE p.total.amount > 1000
-- OR
SELECT u FROM User u WHERE u.name.surname = :surname
SELECT u FROM User u WHERE u.name.title = :title

Value objects enables us to write much more cleaner and readable rules when dealing with the domain rules, application-wide. For example:

$username  = $user->getEmail()->getLocalpart();

or

$blacklist = ['spam4me.io', 'foo.com'];
if(in_array($user->getEmail()->getDomain(), $blacklist)) {
   // ...
}

even

if($company->hasMap()) {
    $latLng = $company->getAddress()->getGeoPoint()->toArray();
    //..
}

class Company
{
    // ...
       
    /**
     * Returns a boolean TRUE if the geolocation of the company is known,
     * FALSE otherwise.
     *
     * @return bool
     */
    public function hasMap()
    {
        return $this->getAddress()->getGeoPoint() !== null;
    }
}

Running Tests

You can run unit tests locally via issuing the command below:

$ composer test

Please make sure that all test are green before creating a PR.

PHPUnit 5.1.6 by Sebastian Bergmann and contributors.

...........                 11 / 11 (100%)

Time: 269 ms, Memory: 7.25Mb

OK (39 tests, 71 assertions)

Contributing

If you want to contribute to ddd-embeddables and make it better, your help is very welcome.

Please take a look our CONTRIBUTING.md before creating a pull request.

Further Reading

Are you interested in Domain Driven Design? Here is a list of good resources to dig in-depth.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].