PHPackages                             hereldar/results - 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. hereldar/results

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

hereldar/results
================

Allows developers to handle the results in any way they choose.

0.9.0(2y ago)26391MITPHPPHP ^8.1.17|^8.2.4|^8.3.0CI passing

Since Mar 21Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/hereldar/php-results)[ Packagist](https://packagist.org/packages/hereldar/results)[ RSS](/packages/hereldar-results/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (15)Used By (1)

Results
=======

[](#results)

[![PHP](https://camo.githubusercontent.com/690c678e4779b521a3a33b0822be68cae4bea60cbb9f335a339cd12f4a927c98/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e31253230746f253230382e342d3737376262332e737667)](https://coveralls.io/github/hereldar/php-results)[![Code Coverage](https://camo.githubusercontent.com/8bbe6149cd013d1480a00efa21b43a5de661cffb77a94574214be5c09fbc5608/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f686572656c6461722f7068702d726573756c7473)](https://app.codecov.io/gh/hereldar/php-results)[![Type Coverage](https://camo.githubusercontent.com/79559deddb1fe3c7f53fe3919646ffe6264012f9d4d22f4aebc475a6fb1f23eb/68747470733a2f2f73686570686572642e6465762f6769746875622f686572656c6461722f7068702d726573756c74732f636f7665726167652e737667)](https://shepherd.dev/github/hereldar/php-results)[![Psalm Level](https://camo.githubusercontent.com/19fe06a9f2dfb57ba4bbc4fc435d5bbf87cb8215d3544a163d968ffead85d108/68747470733a2f2f73686570686572642e6465762f6769746875622f686572656c6461722f7068702d726573756c74732f6c6576656c2e737667)](https://shepherd.dev/github/hereldar/php-results)[![Packagist](https://camo.githubusercontent.com/0e7e8b1436c50ff57f3fe45656a36ae1ffdc16a36fb8a0691cf2cddef3f8f89b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f686572656c6461722f726573756c74732e737667)](https://packagist.org/packages/hereldar/results)[![License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)

This package includes an opinionated version of the `Result` type of Rust. It is not intended to replicate the original type one-to-one, but to allow developers to handle the results in any way they choose.

Use examples
------------

[](#use-examples)

This `Result` type allows ignoring errors without a try-catch block:

```
$value = getValue()->or($default);
```

It also allows throwing the error as a regular exception:

```
doSomething()->orFail();
```

Or throwing a custom exception:

```
doSomething()->orThrow(new MyException());
```

More complex flows can be handled by concatenating operations:

```
$record = fetchRecord()
    ->andThen(updateIt(...))
    ->orElse(insertIt(...))
    ->orFail();
```

And much more:

```
doSomething()
    ->onFailure(logFailure(...))
    ->onSuccess(logSuccess(...))
    ->onSuccess(doSomethingElse(...));
```

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

[](#installation)

Via Composer:

```
composer require hereldar/results
```

Development
-----------

[](#development)

Run the following commands from the project folder:

```
make tests
make static-analysis
make coding-standards
```

To execute:

- A [PHPUnit](https://phpunit.de) test suite.
- [PHPStan](https://phpstan.org/) and [Psalm](https://psalm.dev/) for static code analysis.
- [Easy Coding Standard](https://github.com/easy-coding-standard/easy-coding-standard)to fix coding standards.

Documentation
-------------

[](#documentation)

- [Guide](https://hereldar.github.io/php-results/)
- [Reference](https://hereldar.github.io/php-results/reference/)

Credits
-------

[](#credits)

- [Samuel Maudo](https://github.com/samuelmaudo)

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 93.8% 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 ~52 days

Total

12

Last Release

944d ago

PHP version history (3 changes)v0.1.0PHP ^8.1

0.7.0PHP ^8.1.17|^8.2.4

0.8.0PHP ^8.1.17|^8.2.4|^8.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/e69606567e5c99066ebbe99515ffda4c8659aa53d95ec9b7f7b70065c712244e?d=identicon)[hereldar](/maintainers/hereldar)

---

Top Contributors

[![samuelmaudo](https://avatars.githubusercontent.com/u/248153?v=4)](https://github.com/samuelmaudo "samuelmaudo (60 commits)")[![hereldar](https://avatars.githubusercontent.com/u/83026166?v=4)](https://github.com/hereldar "hereldar (3 commits)")[![google-labs-jules[bot]](https://avatars.githubusercontent.com/in/842251?v=4)](https://github.com/google-labs-jules[bot] "google-labs-jules[bot] (1 commits)")

---

Tags

resultResult-Typeerror handling

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hereldar-results/health.svg)

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

###  Alternatives

[graham-campbell/result-type

An Implementation Of The Result Type

548378.1M7](/packages/graham-campbell-result-type)[ejsmont-artur/php-circuit-breaker

PHP Circuit Breaker component

169964.9k4](/packages/ejsmont-artur-php-circuit-breaker)[liliuwei/thinkphp-jump

适用于thinkphp6.0的跳转扩展

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

PHPackages © 2026

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