PHPackages                             boehm\_s/fun - 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. boehm\_s/fun

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

boehm\_s/fun
============

Functional programming utilities for PHP

1.3.0(5y ago)301.8k2[1 PRs](https://github.com/boehm-s/fun-php/pulls)MITPHPPHP &gt;=7.2CI passing

Since Apr 11Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/boehm-s/fun-php)[ Packagist](https://packagist.org/packages/boehm_s/fun)[ RSS](/packages/boehm-s-fun/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (14)Used By (0)

fun-php [![Build Status](https://camo.githubusercontent.com/6fd8c0988c2ef0200c9d8422697107933af984fa1dd15b719990785cc9f770f9/68747470733a2f2f7472617669732d63692e636f6d2f626f65686d2d732f66756e2d7068702e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/6fd8c0988c2ef0200c9d8422697107933af984fa1dd15b719990785cc9f770f9/68747470733a2f2f7472617669732d63692e636f6d2f626f65686d2d732f66756e2d7068702e7376673f6272616e63683d6d6173746572) [![codecov](https://camo.githubusercontent.com/3d609e110009383fccd0408522ab6053e06242c5e142891136423cf05da361a8/68747470733a2f2f636f6465636f762e696f2f67682f626f65686d2d732f66756e2d7068702f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d4c49575847444d324e4e)](https://codecov.io/gh/boehm-s/fun-php) [![Maintainability](https://camo.githubusercontent.com/ec26b04705ba53f90ce0afffefafbc329fb2c26ba03cdd666e7d5773d8014c1c/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f36313264356461633236396465663265303930302f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/boehm-s/fun-php/maintainability)
==================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#fun-php---)

**fun**ctional programming utilities for PHP ! Inspired by *Ramda*, Javascript, lodash and many other things !

Why ?
-----

[](#why-)

- Because PHP lacks of simple and easy-to-use utilities for functional programming !
- To prove that we can still have fun with PHP (despite the fact that it's PHP) !!!

Installation
============

[](#installation)

```
composer require boehm_s/fun

```

How to use it ?
===============

[](#how-to-use-it-)

You can review the [API Documentation](https://boehm-s.github.io/fun-php/)

Or, if you're familiar with Ramda, you can start writing code right now. As with Ramda, fun-php methods are automatically curried :

`F::map($fn, $array)` ⇔ `F::map($fn)($array)` ⇔ `F::map()($fn)($array)`

Also placeholders are implemented. fun-php placeholder is `F::_` :

`F::map(F::_, $array)($fn)` ⇔ `F::map($fn)(F::_)($array)` ⇔ `F::map(F::_)($fn)($array)`

Example
-------

[](#example)

```
{
  "items": [{
      "id":1,
      "type":"train",
      "users":[
        { "id":1, "name":"Jimmy Page"},
        { "id":5, "name":"Roy Harper"}
      ]
    }, {
      "id":421,
      "type":"hotel",
      "users":[
        { "id":1, "name":"Jimmy Page" },
        { "id":2, "name":"Robert Plant" }
      ]
    }, {
      "id":876,
      "type":"flight",
      "users":[
        { "id":3, "name":"John Paul Jones" },
        { "id":4, "name":"John Bonham" }
      ]
    }]
}
```

Get all users names

```
$get_all_users_names = F::pipe(
    F::prop('items'),
    F::flatMap(F::prop('users')),
    F::map(F::prop('name')),
    F::uniq()
);

$travel = json_decode($travelJSON);

$travels_users = $get_all_users_names($travel);

var_dump($travels_users);  //  ["Jimmy Page", "Roy Harper", "Robert Plant", "John Paul Jones", "John Bonham"]
```

Implemented methods
-------------------

[](#implemented-methods)

**fun-php** is just a bunch of static methods. To use them, juste prefix the following functions with `F::`

### For Lists / Arrays

[](#for-lists--arrays)

functiontypefunctiontype*map*`((a, i, [a]) → b) → [a] → [b]`*flatMap*`((a, i, [a]) → [b]) → [a] → [b]`*filter*`((a, i, [a]) → Bool) → [a] → [a]`*reduce*`((a, b) → a) → a → [b] → a`*each*`(a → _) → [a] → [a]`*find*`((a, i, [a]) → Bool) → [a] → a`*findIndex*`((a, i, [a]) → Bool) → [a] → i`*some*`((a, i, [a]) → Bool) → [a] → Bool`*every*`((a, i, [a]) → Bool) → [a] → Bool`*sort*`((a, a) → Bool) → [a] → [a]`*reverse*`[a] → [a]`*includes*`a → [a] → Bool`*uniq*`[a] → [a]`*splitAt*`Number → [a] → [[a], [a]]`*uniqBy*`(a → b) → [a] → [a]`### For Objects / Associative arrays

[](#for-objects--associative-arrays)

functiontypefunctiontype*prop*`k → {k: v} → v | null`*pick*`[k] → {k: v} → {k: v} | null`*props*`[k] → {k: v} → [v]`*propEq*`k → v → {k: v} → Bool`*propSatisfies*`(v → Bool) → k → {k: v} → Bool`*propOr*`k → d → {k: v} → v | d`*merge*`{k: v} → ({k: v}, ..., {k: v}) → {k: v}`### For function composition

[](#for-function-composition)

functiontype*compose*`((y → z), (x → y), ... ,(a → b)) → (a → z)`*pipe*`((a → b), (b → c), ... , (y → z)) → (a → z)`*partial*`((a, b, ..., n) → x) → [a, b, ...] → ((d, e, ..., n) → x)`### Logical operations

[](#logical-operations)

functiontype*not*`* → Bool`Notes (to myself)
=================

[](#notes-to-myself)

Deploying the doc :

```
git subtree push --prefix doc/dist/html origin gh-pages

```

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance50

Moderate activity, may be stable

Popularity28

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99% 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 ~42 days

Recently: every ~78 days

Total

11

Last Release

1847d ago

PHP version history (2 changes)v1.0PHP ^7.2

v1.2.3PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/be203cd072d319ecb68d39845bbeac71cd1a762620ca027c84c07ab898c4ce2c?d=identicon)[boehm\_s](/maintainers/boehm_s)

---

Top Contributors

[![boehm-s](https://avatars.githubusercontent.com/u/15074274?v=4)](https://github.com/boehm-s "boehm-s (95 commits)")[![SteveALee](https://avatars.githubusercontent.com/u/618922?v=4)](https://github.com/SteveALee "SteveALee (1 commits)")

---

Tags

compositional-datafunction-compositionfunctional-programmingramdajslibraryfunctionalfunctional-programmingfpramda

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/boehm-s-fun/health.svg)

```
[![Health](https://phpackages.com/badges/boehm-s-fun/health.svg)](https://phpackages.com/packages/boehm-s-fun)
```

###  Alternatives

[league/iso3166

ISO 3166-1 PHP Library

69837.6M135](/packages/league-iso3166)[lambdish/phunctional

λ PHP functional library

3632.1M24](/packages/lambdish-phunctional)[mpetrovich/dash

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

10429.7k1](/packages/mpetrovich-dash)[qaribou/immutable.php

Immutable, highly-performant collections, well-suited for functional programming and memory-intensive applications.

347147.4k](/packages/qaribou-immutablephp)[crell/fp

Functional utilities for PHP 8 and later

92490.8k11](/packages/crell-fp)[chemem/bingo-functional

A simple functional programming library.

687.0k3](/packages/chemem-bingo-functional)

PHPackages © 2026

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