PHPackages                             aambr/phpchain - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. aambr/phpchain

ActiveLibrary

aambr/phpchain
==============

1.1.1(9y ago)18.6k1PHP

Since Oct 20Pushed 9y agoCompare

[ Source](https://github.com/aambrozkiewicz/phpchain)[ Packagist](https://packagist.org/packages/aambr/phpchain)[ RSS](/packages/aambr-phpchain/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

phpchain [![Build Status](https://camo.githubusercontent.com/ae5ba1ea9dc0119e75db39798d35daf4c509a652ace533d80bb9e700a7f0e7e9/68747470733a2f2f7472617669732d63692e6f72672f61616d62726f7a6b69657769637a2f706870636861696e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/aambrozkiewicz/phpchain)
=============================================================================================================================================================================================================================================================================================================

[](#phpchain-)

Set of classes that help to create chains of steps to minimize clutter in domain logic.

Install
-------

[](#install)

`composer require aambr/phpchain`

Quick start
-----------

[](#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.

Divide and conquer
------------------

[](#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)`.

Share variables between steps
-----------------------------

[](#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`.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity65

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

3

Last Release

3489d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/788c892fcff5aa60ab6413fbc0b0ee2591bd40bb19bdccd21eae0cf4d8071157?d=identicon)[aleks](/maintainers/aleks)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aambr-phpchain/health.svg)

```
[![Health](https://phpackages.com/badges/aambr-phpchain/health.svg)](https://phpackages.com/packages/aambr-phpchain)
```

###  Alternatives

[laminas/laminas-mvc

Laminas's event-driven MVC layer, including MVC Applications, Controllers, and Plugins

17224.4M365](/packages/laminas-laminas-mvc)[laminas/laminas-mvc-i18n

Integration between laminas-mvc and laminas-i18n

144.5M44](/packages/laminas-laminas-mvc-i18n)[chadicus/slim-oauth2-middleware

OAuth2 middleware for use within a Slim Framework API

48411.9k1](/packages/chadicus-slim-oauth2-middleware)[mouf/pimple-interop

This project is a very simple extension to the Pimple microframework. It adds to Pimple compatibility with the container-interop APIs.

102.4M2](/packages/mouf-pimple-interop)[enlitepro/enlite-monolog

Monolog integration to Laminas

18641.6k](/packages/enlitepro-enlite-monolog)[maglnet/magl-markdown

Provides a ZF2 View Helper to render markdown syntax. It uses third-party libraries for the rendering and you can switch between different renderers.

22178.2k4](/packages/maglnet-magl-markdown)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
