lstrojny / functional-php
Functional primitives for PHP
Fund package maintenance!
1.18.0
2026-03-21 09:05 UTC
Requires
- php: ^7.1|~8
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.17
- phpunit/phpunit: ^7.0 || ^8.0 || ^9.5
- squizlabs/php_codesniffer: ~3.0
- dev-main
- 1.18.0
- 1.17.0
- 1.16.0
- 1.15.0
- 1.14.1
- 1.14.0
- 1.12.0
- 1.11.0
- 1.10.0
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.0
- 1.4.0
- 1.2.4
- 1.2.3
- 1.2.1
- 1.2.0
- 1.0.0
- 1.0.0-alpha5
- 1.0.0-alpha4
- 1.0.0-alpha3
- 1.0.0-alpha2
- 1.0.0-alpha1
- dev-feature/when-unless
- dev-feature/juxt
- dev-feature/pipe
- dev-feature/frequencies
- dev-chore/remove-doctoc
- dev-fix/update-ci-runner
- dev-dev/cleanup
- dev-value_to_key
- dev-psalm
This package is auto-updated.
Last update: 2026-03-21 19:34:38 UTC
README
NOTE: functional-php used to come with a C extension that implemented most of the functions natively. As the performance differences weren’t that huge compared to the maintenance cost it has been removed.
A set of functional primitives for PHP, heavily inspired by Scala’s traversable collection, Dojo’s array functions and Underscore.js
- Works with arrays and everything implementing interface
Traversable - Consistent interface: for functions taking collections and callbacks, first parameter is always the collection, then the callback.
Callbacks are always passed
$value,$index,$collection. Strict comparison is the default but can be changed - Calls 5.3 closures as well as usual callbacks
- All functions reside in namespace
Functionalto not raise conflicts with any other extension or library
Installation
Run the following command in your project root:
composer require lstrojny/functional-php
Docs
Contributing
- Fork and
git clonethe project - Install dependencies via
composer install - Run the tests via
composer run tests - Write code and create a PR
Mailing lists
- General help and development list: http://groups.google.com/group/functional-php
- Commit list: http://groups.google.com/group/functional-php-commits
Thank you
- Richard Quadling and Pierre Joye for Windows build help
- David Soria Parra for various ideas and the userland version of
Functional\flatten() - Max Beutel for
Functional\unique(),Functional\invoke_first(),Functional\invoke_last()and all the discussions - An Phan for many great contributions