PHPackages                             maxiviper117/result-flow - 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. maxiviper117/result-flow

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

maxiviper117/result-flow
========================

A minimal Result type with branch-aware chaining for PHP

v1.11.6(1mo ago)010[5 PRs](https://github.com/Maxiviper117/result-flow/pulls)MITPHPPHP ^8.2CI passing

Since Nov 30Pushed 1mo agoCompare

[ Source](https://github.com/Maxiviper117/result-flow)[ Packagist](https://packagist.org/packages/maxiviper117/result-flow)[ Docs](https://github.com/Maxiviper117/result-flow)[ GitHub Sponsors](https://github.com/Maxiviper117)[ RSS](/packages/maxiviper117-result-flow/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (43)Used By (0)

Result Flow
===========

[](#result-flow)

[![run-tests](https://github.com/Maxiviper117/result-flow/actions/workflows/run-tests.yml/badge.svg)](https://github.com/Maxiviper117/result-flow/actions/workflows/run-tests.yml)[![PHPStan](https://github.com/Maxiviper117/result-flow/actions/workflows/phpstan.yml/badge.svg)](https://github.com/Maxiviper117/result-flow/actions/workflows/phpstan.yml)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![Ask DeepWiki](https://camo.githubusercontent.com/0f5ae213ac378635adeb5d7f13cef055ad2f7d9a47b36de7b1c67dbe09f609ca/68747470733a2f2f6465657077696b692e636f6d2f62616467652e737667)](https://deepwiki.com/Maxiviper117/result-flow)

Minimal, type-safe Result type for explicit success/failure handling in PHP (PHP 8.2+).

Composer:

```
composer require maxiviper117/result-flow
```

Documentation map
-----------------

[](#documentation-map)

- [Home](https://maxiviper117.github.io/result-flow/)
- [Getting Started](https://maxiviper117.github.io/result-flow/getting-started.html)
- [Result Guide](https://maxiviper117.github.io/result-flow/result/)
- [Composition Patterns](https://maxiviper117.github.io/result-flow/result/compositions.html)
- [Batch Processing](https://maxiviper117.github.io/result-flow/result/batch-processing.html)
- [API Reference](https://maxiviper117.github.io/result-flow/api.html)
- [Examples](https://maxiviper117.github.io/result-flow/examples/)

Why Result Flow
---------------

[](#why-result-flow)

- Explicit branches: success and failure are handled intentionally.
- Metadata propagation: context survives across every chain step.
- Predictable semantics: fail-fast and collect-all tools are explicit and separate.
- Type-aware design: PHPStan-friendly templates across public methods.

Quick example
-------------

[](#quick-example)

```
use Maxiviper117\ResultFlow\Result;

$result = Result::ok(['order_id' => 123, 'total' => 42], ['request_id' => 'r-1'])
    ->ensure(fn (array $order) => $order['total'] > 0, 'Order total must be positive')
    ->then(fn (array $order) => Result::ok([
        'saved' => true,
        'id' => $order['order_id'],
    ]));

$output = $result->match(
    onSuccess: fn (array $v) => ['ok' => true, 'data' => $v],
    onFailure: fn ($e) => ['ok' => false, 'error' => (string) $e],
);
```

Deferred operations
-------------------

[](#deferred-operations)

```
use Maxiviper117\ResultFlow\Result;

$result = Result::defer(fn () => loadUserById($id))
    ->then(fn (array $user) => Result::ok(normalizeUser($user)));
```

Retry deferred operations
-------------------------

[](#retry-deferred-operations)

```
use Maxiviper117\ResultFlow\Result;

$result = Result::retryDefer(
    3,
    fn () => callExternalApi($payload),
    delay: 100,
    exponential: true,
);
```

Resource-safe operations
------------------------

[](#resource-safe-operations)

```
use Maxiviper117\ResultFlow\Result;

$result = Result::bracket(
    acquire: fn () => fopen($path, 'r'),
    use: fn ($handle) => fread($handle, 100),
    release: fn ($handle) => fclose($handle),
);
```

Batch workflows
---------------

[](#batch-workflows)

- `Result::mapItems($items, $fn)` for per-item `Result` status.
- `Result::mapAll($items, $fn)` for fail-fast aggregate processing.
- `Result::mapCollectErrors($items, $fn)` for collect-all error reporting.

All batch callbacks use: `fn ($item, $key) => Result|value`.

Laravel Boost
-------------

[](#laravel-boost)

This package ships Laravel Boost source assets so AI agents in downstream consumer apps can generate ResultFlow-aware code.

### Package-shipped guideline source

[](#package-shipped-guideline-source)

- Source file in this package: `resources/boost/guidelines/core.blade.php`
- In a Laravel app that uses Boost, run:

```
php artisan boost:install
```

Boost applies package-shipped guidance within the app AI context.

### Package-shipped central skill source

[](#package-shipped-central-skill-source)

- Source file in this package:
    - `resources/boost/skills/result-flow/SKILL.md`
- The central skill loads only needed concept references from:
    - `resources/boost/skills/result-flow/references/*.md`

### App-level overrides

[](#app-level-overrides)

App teams can define or override guidelines locally:

- `.ai/guidelines/...`

To override a built-in guideline, use the same relative path in `.ai/guidelines`, for example:

- `.ai/guidelines/inertia-react/2/forms.blade.php`

Contributing
------------

[](#contributing)

- Tests: `composer test`
- Static analysis: `composer analyse`
- Rector check: `composer rector-dry`
- Rector apply: `composer rector`
- Format: `composer format`

See [CONTRIBUTING.md](CONTRIBUTING.md).

License
-------

[](#license)

MIT - see `LICENSE.md`.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance91

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 83.1% 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.

###  Release Activity

Cadence

Every ~5 days

Total

23

Last Release

44d ago

Major Versions

v0.1.2 → v1.2.02026-01-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/8151772e6f135b5c2ee200aed37385e5b69a4cc79c15e907f343a98c1b69fe46?d=identicon)[Maxiviper117](/maintainers/Maxiviper117)

---

Top Contributors

[![Maxiviper117](https://avatars.githubusercontent.com/u/11472492?v=4)](https://github.com/Maxiviper117 "Maxiviper117 (98 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (19 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

phpresultResult-Typefunctionalerror handlingmonadeither

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/maxiviper117-result-flow/health.svg)

```
[![Health](https://phpackages.com/badges/maxiviper117-result-flow/health.svg)](https://phpackages.com/packages/maxiviper117-result-flow)
```

###  Alternatives

[lambdish/phunctional

λ PHP functional library

3612.0M23](/packages/lambdish-phunctional)[mpetrovich/dash

A functional programming library for PHP. Inspired by Underscore, Lodash, and Ramda.

10428.9k1](/packages/mpetrovich-dash)[chippyash/monad

Functional programming Monad support

2828.1k8](/packages/chippyash-monad)[transprime-research/piper

PHP Pipe method execution with values from chained method executions

174.6k2](/packages/transprime-research-piper)

PHPackages © 2026

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