PHPackages                             camspiers/php-fp - 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. camspiers/php-fp

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

camspiers/php-fp
================

Functional Programming Helpers

0.2.1(11y ago)17192MITPHPPHP &gt;=5.6.0-dev

Since Aug 10Pushed 11y ago4 watchersCompare

[ Source](https://github.com/camspiers/php-fp)[ Packagist](https://packagist.org/packages/camspiers/php-fp)[ RSS](/packages/camspiers-php-fp/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (3)Versions (6)Used By (0)

Functional Programming Helpers
==============================

[](#functional-programming-helpers)

Currying
--------

[](#currying)

A curryable function returns a new function when called with less arguments than the curryable function requires. The new function returned will have the arguments applied, and will also be a curryable function.

This programming pattern can be used to build up more complex functions from less complex functions.

e.g.

```
// Create a curryable function
$concat = fp\curry(function ($a, $b) { return $a . $b; });

// Create a new function with 'Mr. ' applied
$addTitle = $concat('Mr. ');

echo $addTitle('Spiers');
// Mr. Spiers
```

Composition
-----------

[](#composition)

```
$h = fp\compose($f, $g);
```

Function composition will return a new function (`$h`) which will first apply the second function (`$g`), pass its result into the first (`$f`).

Usage
-----

[](#usage)

### Turning normal functions into curryable functions

[](#turning-normal-functions-into-curryable-functions)

```
$map = fp\curry('array_map');
```

### Create non-closure functions that are curryable

[](#create-non-closure-functions-that-are-curryable)

```
function _tag($tag, $text) {
    return "$text";
}

function tag(...$args) {
    return fp\curry('_tag')->__invoke(...$args);
}

// We now have a paragraph function
$p = tag('p');

// We now have a div function
$div = tag('div');

echo $div($p("Some text"));
// Some text
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

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

Total

5

Last Release

4342d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/51294?v=4)[Cam Spiers](/maintainers/camspiers)[@camspiers](https://github.com/camspiers)

---

Top Contributors

[![camspiers](https://avatars.githubusercontent.com/u/51294?v=4)](https://github.com/camspiers "camspiers (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/camspiers-php-fp/health.svg)

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

###  Alternatives

[arokettu/torrent-file

A class to work with torrent files

2516.7k4](/packages/arokettu-torrent-file)[jxlwqq/chinese-typesetting

Better Typesetting for Chinese

852.1k](/packages/jxlwqq-chinese-typesetting)

PHPackages © 2026

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