2017 © Pedro PelĂĄez
 

library domain

image

biig/domain

  • Friday, July 20, 2018
  • by Nek
  • Repository
  • 7 Watchers
  • 13 Stars
  • 155 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 3 Open issues
  • 14 Versions
  • 2483 % Grown

The README.md

Domain component

Build Status Latest Stable Version License, (*1)

This library is design to help you to build your application with a Domain Design Development approach., (*2)

It is well integrated with:, (*3)

  • Symfony >= 4.3 (for >=3.3 compatibility, install the version 1.5 of the domain component)
  • ApiPlatform >= 2.1
  • Doctrine >=2.5

But you can use it with any PHP project., (*4)

Here are some slides that explain how we get there., (*5)

Features

Domain Events:, (*6)

Drawbacks

This library is build to allow you to use Doctrine models as Domain model. This has some cost: you can't instantiate domain model by hand anymore. This means that you need a factory for any of the usage of your domain model., (*7)

This component provides the implementation for Symfony serializer and Doctrine. For your own needs you should use the class (service if you use the bundle) Biig\Component\Domain\Model\Instantiator\Instantiator., (*8)

Installation

composer require biig/domain

Basic usage

class YourModel extends DomainModel
{
    public const CREATION = 'creation';
    public function __construct()
    {
        $this->dispatch(new DomainEvent($this), self::CREATION);
    }
}
class DomainRule implements DomainRuleInterface
{
    public function on()
    {
        return YourModel::CREATION;
    }

    public function execute(DomainEvent $event)
    {
        // Do Something on your model creation
    }
}

As your model needs a dispatcher you need to call the setDispatcher() method any time you create a new instance of your model. To avoid doing this manually you can use the Instantiator that the library provides., (*9)

It doesn't use the constructor to add the dispatcher because in PHP you can create objects without the constructor. For instance, that's what Doctrine does., (*10)

Integration to Symfony

Use the bundle :, (*11)

<?php
// config/bundles.php

return [
    // ...
    Biig\Component\Domain\Integration\Symfony\DomainBundle::class => ['all' => true],
];

Learn more about Symfony Integration, (*12)

Versions

Version Status Documentation Symfony Version  PHP Version
1.x Maintained v1 '>= 3.3 && <5' '>= 7.1'
2.x Latest v2 '>= 4.3' '>= 7.1'

The Versions

10/04 2018

dev-feature/correct-error-on-db-flushing

dev-feature/correct-error-on-db-flushing

  Sources   Download

MIT

The Requires

 

The Development Requires

27/03 2018
02/03 2018
01/03 2018