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

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

ghostwriter/result
==================

Provides a Result type implementation for PHP

2.0.0(1y ago)23.5M—8%4BSD-3-ClausePHPPHP &gt;=8.4CI passing

Since May 19Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/ghostwriter/result)[ Packagist](https://packagist.org/packages/ghostwriter/result)[ Docs](https://github.com/ghostwriter/result)[ GitHub Sponsors](https://github.com/sponsors/ghostwriter)[ RSS](/packages/ghostwriter-result/feed)WikiDiscussions 2.0.x Synced 1mo ago

READMEChangelog (9)Dependencies (2)Versions (25)Used By (4)

Result
======

[](#result)

[![GitHub Sponsors](https://camo.githubusercontent.com/fe280036cb734a4daba105621a2adcb05cb67cb7ac6ce5bdee1f1e08535915d2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73706f6e736f72732f67686f73747772697465723f6c6162656c3d53706f6e736f722b4067686f73747772697465722f726573756c74266c6f676f3d4769744875622b53706f6e736f7273)](https://github.com/sponsors/ghostwriter)[![Automation](https://github.com/ghostwriter/result/actions/workflows/automation.yml/badge.svg)](https://github.com/ghostwriter/result/actions/workflows/automation.yml)[![Supported PHP Version](https://camo.githubusercontent.com/a23369056576143eb089463a30ed40d7766419649c8ac7a44d3dd2abaa2c6263/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f67686f73747772697465722f726573756c743f636f6c6f723d383839326266)](https://www.php.net/supported-versions)[![Downloads](https://camo.githubusercontent.com/1b9037c3d0c7c89455c965ac2a3b13c1a1ea1ce22fd14e063fcd491db1e80fdc/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f64742f67686f73747772697465722f726573756c743f636f6c6f723d626c7565)](https://packagist.org/packages/ghostwriter/result)

Provides a **`Result`** type implementation for PHP using [`ghostwriter/option`](https://github.com/ghostwriter/option)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require ghostwriter/result
```

Usage
-----

[](#usage)

```
use Ghostwriter\Result\Failure;
use Ghostwriter\Result\Success;

// --- Success ---
$success = Success::new('Hello world!');
$success->get(); // 'Hello world!'

// --- Failure ---
$failure = Failure::new(new ExampleException());
$failure->get(); // throws: ResultException
$failure->getOr('Fallback'); // 'Fallback'
$failure->getError(); // returns: instance of ExampleException

// --- Example ---
function divide(int $x, int $y): ResultInterface
{
    if ($y === 0) {
        return Result::failure(new DivisionByZeroError);
    }

    return Result::success($x / $y);
}

divide(1, 0); // Error(DivisionByZeroError)
divide(1, 1); // Success(1)
```

### Credits

[](#credits)

- [Nathanael Esayeas](https://github.com/ghostwriter)
- [All Contributors](https://github.com/ghostwriter/result/contributors)

### Changelog

[](#changelog)

Please see [CHANGELOG.md](./CHANGELOG.md) for more information on what has changed recently.

### License

[](#license)

Please see [LICENSE](./LICENSE) for more information on the license that applies to this project.

### Security

[](#security)

Please see [SECURITY.md](./SECURITY.md) for more information on security disclosure process.

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance69

Regular maintenance activity

Popularity45

Moderate usage in the ecosystem

Community13

Small or concentrated contributor base

Maturity75

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~100 days

Total

15

Last Release

54d ago

Major Versions

0.3.0 → 1.0.02022-09-29

1.3.x-dev → 2.0.02025-02-10

0.1.x-dev → 2.0.x-dev2026-03-25

2.1.x-dev → 3.0.x-dev2026-03-25

PHP version history (8 changes)0.1.0PHP &gt;=8.0, &lt;8.2

0.2.0PHP &gt;=8.0,&lt;8.2

1.0.1PHP &gt;=8.0,&lt;8.3

1.2.0PHP &gt;=8.1,&lt;8.3

1.3.0PHP &gt;=8.1,&lt;8.4

1.2.x-devPHP &gt;=8.3

2.0.0PHP &gt;=8.4

0.1.x-devPHP ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1dbb0131801cc451dad9917ab29aa823b25d7eebc9f3875a9d481d109bdb44ee?d=identicon)[ghostwriter](/maintainers/ghostwriter)

---

Top Contributors

[![ghostwriter](https://avatars.githubusercontent.com/u/9754361?v=4)](https://github.com/ghostwriter "ghostwriter (1179 commits)")

---

Tags

ghostwriterphpresultresult-typeresultghostwriter

### Embed Badge

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

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

###  Alternatives

[graham-campbell/result-type

An Implementation Of The Result Type

552378.1M7](/packages/graham-campbell-result-type)[liliuwei/thinkphp-jump

适用于thinkphp6.0的跳转扩展

2874.4k1](/packages/liliuwei-thinkphp-jump)

PHPackages © 2026

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