Download the PHP package carlosbuenosvinos/ddd without Composer

On this page you can find all versions of the php package carlosbuenosvinos/ddd. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ddd

carlosbuenosvinos/ddd

Build Status

This library will help you with typical DDD scenarios, for now:

Sample Projects

There are some projects developed using carlosbuenosvinos/ddd library. Check some of them to see how to use it:

Application Services

Application Service Interface

Consider an Application Service that registers a new user in your application.

$signInUserService = new SignInUserService(
    $em->getRepository('MyBC\Domain\Model\User\User')
);

$response = $signInUserService->execute(
    new SignInUserRequest(
        '[email protected]',
        'thisisnotasecretpassword'
    )
);

$newUserCreated = $response->getUser();
//...

We need to pass in the constructor all the dependencies. In this case, the User repository. As DDD explains, the Doctrine repository is implementing a generic interface for User repositories.

<?php

namespace MyBC\Application\Service\User;

use MyBC\Domain\Model\User\User;
use MyBC\Domain\Model\User\UserAlreadyExistsException;
use MyBC\Domain\Model\User\UserRepository;

use Ddd\Application\Service\ApplicationService;

/**
 * Class SignInUserService
 * @package MyBC\Application\Service\User
 */
class SignInUserService implements ApplicationService
{
    /**
     * @var UserRepository
     */
    private $userRepository;

    /**
     * @param UserRepository $userRepository
     */
    public function __construct(UserRepository $userRepository)
    {
        $this->userRepository = $userRepository;
    }

    /**
     * @param SignInUserRequest $request
     * @return SignInUserResponse
     * @throws UserAlreadyExistsException
     */
    public function execute($request = null)
    {
        $email = $request->email();
        $password = $request->password();

        $user = $this->userRepository->userOfEmail($email);
        if (null !== $user) {
            throw new UserAlreadyExistsException();
        }

        $user = new User(
            $this->userRepository->nextIdentity(),
            $email,
            $password
        );

        $this->userRepository->persist($user);

        return new SignInUserResponse($user);
    }
}

I suggest to make your Application Services implement the following interface following the command pattern.

/**
 * Interface ApplicationService
 * @package Ddd\Application\Service
 */
interface ApplicationService
{
    /**
     * @param $request
     * @return mixed
     */
    public function execute($request = null);
}

Transactions

Application Services should manage transactions when dealing with database persistence strategies. In order to manage it cleanly, I provide an Application Service decorator that wraps an Application Service an executes it inside a transactional boundary.

The decorator is the class. In order to create one, you need the non transactional Application Service and a Transactional Session. We provide different types of Transactional Sessions. See how to do it with Doctrine.

Doctrine Transactional Application Services

For the Doctrine Transactional Session, pass the EntityManager instance.

/** @var EntityManager $em */
$txSignInUserService = new TransactionalApplicationService(
    new SignInUserService(
        $em->getRepository('MyBC\Domain\Model\User\User')
    ),
    new DoctrineSession($em)
);

$response = $txSignInUserService->execute(
    new SignInUserRequest(
        '[email protected]',
        'thisisnotasecretpassword'
    )
);

$newUserCreated = $response->getUser();
//...

As you can see, the use case creation and execution is the same as the non transactional, the only difference is the decoration with the Transactional Application Service.

As a collateral benefit, the Doctrine Session manages internally the method, so you don't need to add a in your Domain neither your infrastructure.

Asynchronous AMQP listeners

This library is capable to support asynchronous messaging in order to make Bounded Context capable to listen to other Bounded Context's events in an efficient way. The base for this is the both the amqp and the react's event loop. In addition, to support more efficient event loopings, we recommend the installation of one of this extensions

The usage of any of this extensions is handled by ReactPHP's event-loop in a totally transparent way.

Example

Supose we need to listen to the event triggered via messaging from another bounded context. The following, is an example of a AMQP exchange listener that listents to the event.

And this is a possible command to create AMQP workers

AMQP Message producer

The intention of the AMQP message producer is to be composed in some other class. The following is an example of the usage of the AMQP message producer.


All versions of ddd with dependencies

PHP Build Version
Package Version
Requires jms/serializer Version ~1.1
react/event-loop Version ^0.4.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package carlosbuenosvinos/ddd contains the following files

Loading the files please wait ....