2017 © Pedro Peláez
 

library buxus

A framework-agnostic, minimal & lightweight PHP command bus

image

0x13a/buxus

A framework-agnostic, minimal & lightweight PHP command bus

  • Saturday, February 18, 2017
  • by diegomariani
  • Repository
  • 1 Watchers
  • 19 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Buxus - A PHP Command Bus

Build Status License Coverage Status composer.lock, (*1)

Why a PHP Command Bus

  • Keeps Application logic separated from Domain logic
  • Commands enforce discoverability
  • Command Handlers enforce Single Responsibility Principle
  • Can be easily extended (decorated)

Read more here Building a PHP Command Bus, (*2)

Prerequisites

Install

Install using composer, (*3)

composer require 0x13a/buxus

Run test suite, (*4)

vendor/bin/phpunit

Check code style, (*5)

composer check-cs

Check Object Calisthenics rules, (*6)

composer check-calisthenics

Getting started

You can simply define your Command => CommandHandler map and then instantiate your command bus, ready to use., (*7)

<?php

require_once __DIR__ . '/vendor/autoload.php';

$commandHandlerMap = [
    CreateProductCommand::class => new CreateProductHandler()
];

$standardCommandBus = new \Buxus\Bus\StandardCommandBus(
    new \Buxus\Handler\StandardCommandHandlerLocator(
        new \Buxus\Map\InMemoryCommandHandlerMap($commandHandlerMap)
    )
);

$loggedCommandBus->dispatch(new CreateProductCommand('beer'));

Extending Command Bus

If you want to extend the default Command Bus functionality, you can decorate it, creating a new one based on your needs., (*8)

See Decorator Pattern, (*9)

<?php

require_once __DIR__ . '/vendor/autoload.php';

$commandHandlerMap = [
    CreateProductCommand::class => new CreateProductHandler()
];

$standardCommandBus = new \Buxus\Bus\StandardCommandBus(
    new \Buxus\Handler\StandardCommandHandlerLocator(
        new \Buxus\Map\InMemoryCommandHandlerMap($commandHandlerMap)
    )
);

$loggedCommandBus = new LoggedCommandBus(
    $standardCommandBus,
    new Logger()
);

$loggedCommandBus->dispatch(new CreateProductCommand('beer'));

In this project

License

Buxus is licensed under the MIT license. See License File for more information, (*10)

The Versions

18/02 2017

dev-master

9999999-dev

A framework-agnostic, minimal & lightweight PHP command bus

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Diego Mariani

command command bus php command php commmand bus

31/12 2016

v0.3

0.3.0.0

A framework-agnostic, minimal & lightweight PHP command bus

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Diego Mariani

command command bus php command php commmand bus

31/12 2016

v0.2

0.2.0.0

A framework-agnostic, minimal & lightweight PHP command bus

  Sources   Download

MIT

The Requires

 

by Diego Mariani

command command bus php command php commmand bus

31/12 2016

v0.1

0.1.0.0

A framework-agnostic, minimal & lightweight PHP command bus

  Sources   Download

The Requires

 

by Diego Mariani