PHPackages                             endoumame/php-monad - 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. endoumame/php-monad

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

endoumame/php-monad
===================

📦 Implemented the concept of monads in functional programming in PHP.

v1.3.0(3mo ago)0530[1 PRs](https://github.com/endoumame/php-monad/pulls)MITPHPPHP &gt;=8.3CI passing

Since Feb 10Pushed 3mo agoCompare

[ Source](https://github.com/endoumame/php-monad)[ Packagist](https://packagist.org/packages/endoumame/php-monad)[ RSS](/packages/endoumame-php-monad/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (6)Dependencies (14)Versions (10)Used By (0)

PHP Monad
=========

[](#php-monad)

[![Packagist Version](https://camo.githubusercontent.com/a1648256189b054e94e20b3ca742adc3f42c5352705c0460b32651a2297eb3ad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656e646f756d616d652f7068702d6d6f6e6164)](https://packagist.org/packages/endoumame/php-monad)[![PHP Version](https://camo.githubusercontent.com/106cce3f834e5a51df8df1ce9679af1751bccc1c9efb9c92462b76f84bc0c4b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f656e646f756d616d652f7068702d6d6f6e6164)](https://packagist.org/packages/endoumame/php-monad)[![PHPStan](https://github.com/endoumame/php-monad/actions/workflows/phpstan.yml/badge.svg)](https://github.com/endoumame/php-monad/actions/workflows/phpstan.yml)[![Documentation](https://github.com/endoumame/php-monad/actions/workflows/deploy-docs.yml/badge.svg)](https://github.com/endoumame/php-monad/actions/workflows/deploy-docs.yml)[![License](https://camo.githubusercontent.com/14b737deff888457aa4f085bbdde4633e0f92fa1c9d9aa53e6c3d4387db4fcac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f656e646f756d616d652f7068702d6d6f6e6164)](https://github.com/endoumame/php-monad/blob/main/LICENSE)

関数型プログラミングのモナド概念を PHP で実装したライブラリです。Rust の `Option` / `Result` 型に着想を得ています。

インストール
------

[](#インストール)

```
composer require endoumame/php-monad
```

使用例
---

[](#使用例)

### Option

[](#option)

```
use EndouMame\PhpMonad\Option;

$name = Option\fromValue($user['name'] ?? null)
    ->map(fn($n) => strtoupper($n))
    ->filter(fn($n) => strlen($n) > 0)
    ->unwrapOr('Anonymous');
```

### Result

[](#result)

```
use EndouMame\PhpMonad\Result;

$result = Result\fromThrowable(
    fn() => json_decode($json, flags: JSON_THROW_ON_ERROR),
    fn($e) => "Parse error: {$e->getMessage()}"
);

$data = $result->map(fn($d) => $d['key'])->unwrapOr(null);
```

ドキュメント
------

[](#ドキュメント)

詳細なガイドと API リファレンスは [ドキュメントサイト](https://endoumame.github.io/php-monad/) を参照してください。

要件
--

[](#要件)

- PHP 8.3 以上

ライセンス
-----

[](#ライセンス)

MIT License

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance82

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.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 ~8 days

Total

6

Last Release

92d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8b178ebfdb6cfb13043a0c5c82c1e64613777987ecb3083cffe6e300539429ca?d=identicon)[endoumame](/maintainers/endoumame)

---

Top Contributors

[![endoumame](https://avatars.githubusercontent.com/u/87973394?v=4)](https://github.com/endoumame "endoumame (100 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (11 commits)")

---

Tags

functional-programmingoption-typephpresult-type

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/endoumame-php-monad/health.svg)

```
[![Health](https://phpackages.com/badges/endoumame-php-monad/health.svg)](https://phpackages.com/packages/endoumame-php-monad)
```

###  Alternatives

[m6web/tornado

A library for asynchronous programming.

8256.7k](/packages/m6web-tornado)[shreejan/actionable-column

Interactive table column with clickable actions for Filament v4 and v5

174.6k](/packages/shreejan-actionable-column)

PHPackages © 2026

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