PHPackages                             mindplay/spatch - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mindplay/spatch

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

mindplay/spatch
===============

Recursive dispatch and delivery

17PHP

Since Oct 28Pushed 11y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

mindplay/spatch
---------------

[](#mindplayspatch)

This library is more about defining the flow of dispatch and delivery in a web application, more so than actually implementing anything.

The goal is to separate the output of headers and content from any other activities that do not produce output.

There are three important reasons to enforce this separation:

1. Separation: it is easier to understand code that deals exclusively with output *or* behavior, never with both.
2. Control: avoid PHP gotchas where some operation caused output to start prematurely, preventing you from sending a header or setting session a variable, etc.
3. Testing: separation enables testing in stages, e.g. testing the result of dispatch, such as the selected view-template and variables, versus actually testing what gets rendered.

Two interfaces define a pair of concepts: two types of result which may be returned e.g. by action-methods in controllers:

- **Dispatchable** results do *not* send headers or content - they simply dispatch and perform whatever action it is they perform, which could be anything, as long as it doesn't cause any headers or content to be output.
- **Deliverable** results actually deliver the result, which means sending headers and/or content - this could be anything, from a simple HTTP status code for redirection, to rendering a view or sending an image or file.

The two interfaces as such are similar - `Dispatchable::dispatch()` should return either another `Dispatchable`, or a `Deliverable`, whereas `Deliverable::deliver()` should return nothing and produce a response.

A simple `Dispatcher` class is included, which will accept a `Dispatchable` or `Deliverable` - it will `dispatch()` until a final `Deliverable` is returned, and then finally `deliver()` the result.

The dispatcher enforces separation and flow by throwing an exception if the final result is not a `Deliverable`, and it will also throw if a `Dispatchable`produces any output prematurely.

This may be easier to understand by actually reading the source code of the `Dispatcher` which is just a few lines of code.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9445f567f43ee7a963270651e40e533634586f959e4df3d5398d001b1cb49be8?d=identicon)[mindplay.dk](/maintainers/mindplay.dk)

---

Top Contributors

[![mindplay-dk](https://avatars.githubusercontent.com/u/103348?v=4)](https://github.com/mindplay-dk "mindplay-dk (1 commits)")

### Embed Badge

![Health badge](/badges/mindplay-spatch/health.svg)

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

PHPackages © 2026

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