2017 © Pedro Peláez
 

library phpchain

image

aambr/phpchain

  • Friday, October 28, 2016
  • by aleks
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8,286 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

phpchain Build Status

Set of classes that help to create chains of steps to minimize clutter in domain logic., (*1)

Install

composer require aambr/phpchain, (*2)

Quick start

$dispatcher = new ChainDispatcher($dependencyInjectionContainer);
$dispatcher->chain('user.register')->define([
  'Steps\CreateUserStep', Steps\CreateProfileStep::class, 'sendWelcomeEmail'
]); // all of these will be resolved by dependency container unless 
    // there is a concrete ChainStep object ready

$dispatcher->chain('user.register')->dispatch()->execute(new \ArrayObject([
  'username' => 'valid-username',
  'email' => 'valid@email.com'
]));

ChainDispatcher accepts any depenendecy injection container which extends \ArrayObject to resolve each step depenendecy., (*3)

Divide and conquer

The goal is to devide complex domain logic into individual steps that can be reused in future processes. Create your own steps by inheriting ChainStep and implement logic in process(\ArrayObject $input)., (*4)

Share variables between steps

Steps can share variables between each other by altering $input keys, which is possible because we are passing \ArrayObject instance reference instead an array which is passed by value. For example CreateUserStep after successful action can set $input['user'] = $createdUser, which then can be used by sendWelcomeEmail., (*5)

The Versions

28/10 2016

dev-master

9999999-dev

  Sources   Download

The Requires

 

The Development Requires

by Aleksander Ambrozkiewicz

28/10 2016

1.1.1

1.1.1.0

  Sources   Download

The Requires

 

The Development Requires

by Aleksander Ambrozkiewicz

27/10 2016

1.1

1.1.0.0

  Sources   Download

The Requires

 

The Development Requires

by Aleksander Ambrozkiewicz

20/10 2016

1.0.1

1.0.1.0

  Sources   Download

The Development Requires

by Aleksander Ambrozkiewicz