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

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

endou-mame/php-monad
====================

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

v1.0.2(4mo ago)06[1 PRs](https://github.com/endou-mame/php-monad/pulls)2MITPHPPHP &gt;=8.3CI passing

Since Feb 10Pushed 3mo agoCompare

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

READMEChangelog (6)Dependencies (7)Versions (4)Used By (2)

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

39

—

LowBetter than 84% of packages

Maintenance78

Regular maintenance activity

Popularity6

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity52

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 ~3 days

Total

3

Last Release

137d ago

### Community

Maintainers

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

---

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/endou-mame-php-monad/health.svg)

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

PHPackages © 2026

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