Code Monkey home page Code Monkey logo

domaincomponent's Introduction

Domain component

Build Status Latest Stable Version License

This library is design to help you to build your application with a Domain Design Development approach.

It is well integrated with:

  • Symfony >= 3.3
  • ApiPlatform >= 2.1
  • Doctrine >=2.5

But you can use it with any PHP project.

Here are some slides that explain how we get there.

Features

Domain Events:

Installation

composer require biig/domain

Basic usage

class YourModel extends DomainModel
{
    public const CREATION = 'creation';
    public function __construct()
    {
        $this->dispatch(self::CREATION, new DomainEvent($this));
    }
}
class DomainRule implements DomainRuleInterface
{
    public function on()
    {
        return YourModel::CREATION;
    }
    
    public function execute(DomainEvent)
    {
        // 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.

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.

Integration to Symfony

Use the bundle :

<?php
// In your Kernel class
public function registerBundles()
{
      return array(
          // ...
          new \Biig\Component\Domain\Integration\Symfony\DomainBundle(),
          // ...
      );
}

domaincomponent's People

Contributors

nek- avatar babeou avatar awkan avatar pborreli avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.