PHPackages                             andres-ml/fpl - 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. andres-ml/fpl

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

andres-ml/fpl
=============

Functional PHP library

1.0.0(5mo ago)01.5k[1 PRs](https://github.com/andres-ml/fpl/pulls)MITPHPPHP &gt;=8,&lt;9CI passing

Since Mar 29Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/andres-ml/fpl)[ Packagist](https://packagist.org/packages/andres-ml/fpl)[ RSS](/packages/andres-ml-fpl/feed)WikiDiscussions master Synced 1mo ago

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

Functional PHP Library
======================

[](#functional-php-library)

This library provides a series of curried, data-last functions commonly used within the functional programming paradigm.

```
use function Aml\Fpl\{compose, partial, last};

$lastWord = compose(last(...), partial(explode(...), ' '));
$lastWord('some words in a sentence'); // 'sentence'
```

The new PHP 8.5 pipe operator and the recent variadic placeholder make this library less necessary, but you still may find it useful if you dislike the boilerplate and the lack of partial application.

```
// idiomatic php
'some words in a BUG sentence'
    |> (fn($x) => explode(' ', $x))
    |> (fn($x) => array_filter($x, fn(string $word) => $word !== 'BUG'))
    |> (fn($x) => explode(' ', $x));
    // 'some words in a sentence'

// with this library
use function Aml\Fpl\{partial as _, filter};
'some words in a BUG sentence'
    |> _(explode(...), ' ')
    |> filter(fn(string $word) => $word !== 'BUG')
    |> _(implode(...), ' ');
    // 'some words in a sentence'
```

API
---

[](#api)

Full api documentation can be found in [docs/api.md](docs/api.md)

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

[](#installation)

```
composer require andres-ml/fpl

```

Non-curried functions
---------------------

[](#non-curried-functions)

If you want, you can use the original function definitions instead. Note that these are not curried and don't have their corresponding `const` versions.

```
use function Aml\Fpl\functions\{map};
```

Arrays and iterators
--------------------

[](#arrays-and-iterators)

List-related functions return an array when they receive an array parameter, but they return iterators when receiving iterators (and can thus behave lazily). You can force laziness over an initial array by previously using `toIterator` or finish off with an array by ending with `toArray`:

```
use Aml\Fpl;

$lowerThan4 = function($x) { return $x < 4; };

Fpl\takeWhile($lowerThan4, [0, 1, 2, 3, 4, 5]); // [0, 1, 2, 3]

$pickLowerThan4 = Fpl\compose(
    Fpl\toArray
    Fpl\takeWhile($lowerThan4),
    Fpl\counter
);

$pickLowerThan4(); // [0, 1, 2, 3]
```

Code generation
---------------

[](#code-generation)

Functions are defined on `src/api/*.php`. They are split among different files but share the `Aml\Fpl\functions` namespace. All functions defined on those files not beginning with an underscore `_` will be parsed and added to `build/api.php` as calls to their curried versions.

Code can be generated by running `make code`, which uses `src/build.php`.

Documentation is also automatically generated through `make docs`, which uses `src/make-docs.php`.

Testing
-------

[](#testing)

Testing is done through phpunit: `./vendor/bin/phpunit tests` or `make test`

Note on performance
-------------------

[](#note-on-performance)

Automatic currying and automatic array/iter support have a performance overhead. Be wary of using them in a time-critical loop; a native `array_map` will always be faster than other implementations of `map`.

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance82

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

4

Last Release

153d ago

Major Versions

v0.2.1 → 1.0.02025-12-06

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

v0.2.1PHP &gt;=7.2,&lt;9

1.0.0PHP &gt;=8,&lt;9

### Community

Maintainers

![](https://www.gravatar.com/avatar/485d3a19a3843896470f8d9d516c6b4af2d50a8d19b7dd5d4e197358304a55ae?d=identicon)[andres-ml](/maintainers/andres-ml)

---

Top Contributors

[![andres-ml](https://avatars.githubusercontent.com/u/21081145?v=4)](https://github.com/andres-ml "andres-ml (27 commits)")

---

Tags

phpfunctional

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/andres-ml-fpl/health.svg)

```
[![Health](https://phpackages.com/badges/andres-ml-fpl/health.svg)](https://phpackages.com/packages/andres-ml-fpl)
```

###  Alternatives

[lambdish/phunctional

λ PHP functional library

3612.0M23](/packages/lambdish-phunctional)[akamon/phunctional

λ PHP functional library

3609.4k](/packages/akamon-phunctional)[mpetrovich/dash

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

10428.9k1](/packages/mpetrovich-dash)[krak/fn

Functional library for php with proper currying

2419.0k3](/packages/krak-fn)[transprime-research/piper

PHP Pipe method execution with values from chained method executions

174.6k2](/packages/transprime-research-piper)

PHPackages © 2026

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