{"id":43432548,"url":"https://github.com/boehm-s/fun-php","last_synced_at":"2026-02-02T19:29:46.523Z","repository":{"id":48408138,"uuid":"251420777","full_name":"boehm-s/fun-php","owner":"boehm-s","description":"Functional programming utilities for PHP","archived":false,"fork":false,"pushed_at":"2021-08-12T17:26:17.000Z","size":1002,"stargazers_count":29,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-11-20T12:22:11.227Z","etag":null,"topics":["compositional-data","function-composition","functional-programming","ramdajs"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boehm-s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-30T20:27:55.000Z","updated_at":"2023-05-20T22:19:38.000Z","dependencies_parsed_at":"2022-09-22T00:03:42.228Z","dependency_job_id":null,"html_url":"https://github.com/boehm-s/fun-php","commit_stats":null,"previous_names":[],"tags_count":11,"template":null,"template_full_name":null,"purl":"pkg:github/boehm-s/fun-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehm-s%2Ffun-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehm-s%2Ffun-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehm-s%2Ffun-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehm-s%2Ffun-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boehm-s","download_url":"https://codeload.github.com/boehm-s/fun-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehm-s%2Ffun-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29017962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T18:51:31.335Z","status":"ssl_error","status_checked_at":"2026-02-02T18:49:20.777Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compositional-data","function-composition","functional-programming","ramdajs"],"created_at":"2026-02-02T19:29:46.445Z","updated_at":"2026-02-02T19:29:46.511Z","avatar_url":"https://github.com/boehm-s.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fun-php ![Build Status](https://travis-ci.com/boehm-s/fun-php.svg?branch=master) [![codecov](https://codecov.io/gh/boehm-s/fun-php/branch/master/graph/badge.svg?token=LIWXGDM2NN)](https://codecov.io/gh/boehm-s/fun-php) [![Maintainability](https://api.codeclimate.com/v1/badges/612d5dac269def2e0900/maintainability)](https://codeclimate.com/github/boehm-s/fun-php/maintainability)\n\n**fun**ctional programming utilities for PHP ! Inspired by *Ramda*, Javascript, lodash and many other things !\n\n## Why ? \n\n- Because PHP lacks of simple and easy-to-use utilities for functional programming !\n- To prove that we can still have fun with PHP (despite the fact that it's PHP) !!!\n\n# Installation \n\n```\ncomposer require boehm_s/fun\n```\n\n# How to use it ?\n\nYou can review the [API Documentation](https://boehm-s.github.io/fun-php/)\n\nOr, if you're familiar with Ramda, you can start writing code right now. As with Ramda, fun-php methods are automatically curried : \n\n`F::map($fn, $array)` \u0026nbsp; ⇔  \u0026nbsp; `F::map($fn)($array)` \u0026nbsp; ⇔  \u0026nbsp; `F::map()($fn)($array)`\n\nAlso placeholders are implemented. fun-php placeholder is `F::_` : \n\n`F::map(F::_, $array)($fn)` \u0026nbsp; ⇔  \u0026nbsp; `F::map($fn)(F::_)($array)` \u0026nbsp; ⇔  \u0026nbsp; `F::map(F::_)($fn)($array)`\n\n\n## Example\n\n```json\n{\n  \"items\": [{\n      \"id\":1,\n      \"type\":\"train\",\n      \"users\":[\n        { \"id\":1, \"name\":\"Jimmy Page\"},\n        { \"id\":5, \"name\":\"Roy Harper\"}\n      ]\n    }, {\n      \"id\":421,\n      \"type\":\"hotel\",\n      \"users\":[\n        { \"id\":1, \"name\":\"Jimmy Page\" }, \n        { \"id\":2, \"name\":\"Robert Plant\" }\n      ]\n    }, {\n      \"id\":876,\n      \"type\":\"flight\",\n      \"users\":[\n        { \"id\":3, \"name\":\"John Paul Jones\" },\n        { \"id\":4, \"name\":\"John Bonham\" }\n      ]\n    }]\n}\n```\n\nGet all users names \n\n```php\n$get_all_users_names = F::pipe(\n    F::prop('items'),\n    F::flatMap(F::prop('users')),\n    F::map(F::prop('name')),\n    F::uniq()\n);\n\n$travel = json_decode($travelJSON);\n\n$travels_users = $get_all_users_names($travel);\n\nvar_dump($travels_users);  //  [\"Jimmy Page\", \"Roy Harper\", \"Robert Plant\", \"John Paul Jones\", \"John Bonham\"]\n```\n\n\n## Implemented methods\n\n**fun-php** is just a bunch of static methods. To use them, juste prefix the following functions with `F::`\n\n### For Lists / Arrays\n\n| function   | type                                | function    | type                                |\n|------------|-------------------------------------|-------------|-------------------------------------|\n| *map*      | `((a, i, [a]) → b) → [a] → [b]`     | *flatMap*   | `((a, i, [a]) → [b]) → [a] → [b]`   |\n| *filter*   | `((a, i, [a]) → Bool) → [a] → [a]`  | *reduce*    | `((a, b) → a) → a → [b] → a`        |\n| *each*     | `(a → _) → [a] → [a]`               |             |                                     |\n| *find*     | `((a, i, [a]) → Bool) → [a] → a`    | *findIndex* | `((a, i, [a]) → Bool) → [a] → i`    |\n| *some*     | `((a, i, [a]) → Bool) → [a] → Bool` | *every*     | `((a, i, [a]) → Bool) → [a] → Bool` |\n| *sort*     | `((a, a) → Bool) → [a] → [a]`       | *reverse*   | `[a] → [a]`                         |\n| *includes* | `a → [a] → Bool`                    | *uniq*      | `[a] → [a]`                         |\n| *splitAt*  | `Number → [a] → [[a], [a]]`         | *uniqBy*    | `(a → b) → [a] → [a]`               |\n|            |                                     |             |                                     |\n\n### For Objects / Associative arrays\n\n| function | type                      | function        | type                                      |\n|----------|---------------------------|-----------------|-------------------------------------------|\n| *prop*   | `k → {k: v} → v \\| null`  | *pick*          | `[k] → {k: v} → {k: v} \\| null`           |\n| *props*  | `[k] → {k: v} → [v]`      |                 |                                           |\n| *propEq* | `k → v → {k: v} → Bool`   | *propSatisfies* | `(v → Bool) → k → {k: v} → Bool`          |\n| *propOr* | `k → d → {k: v} → v \\| d` | *merge*         | `{k: v} → ({k: v}, ..., {k: v}) → {k: v}` |\n\n### For function composition\n\n| function  | type                                                        |\n| --------- | ----------------------------------------------------------- |\n| *compose* | `((y → z), (x → y), ... ,(a → b)) → (a → z)`                |\n| *pipe*    | `((a → b), (b → c), ... , (y → z)) → (a → z)`               |\n| *partial* | `((a, b, ..., n) → x) → [a, b, ...] → ((d, e, ..., n) → x)` |\n\n### Logical operations\n\n| function  | type          |\n| --------- | ------------- |\n| *not*     | `* → Bool`    |\n\n\n# Notes (to myself)\n\nDeploying the doc : \n\n```\ngit subtree push --prefix doc/dist/html origin gh-pages\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboehm-s%2Ffun-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboehm-s%2Ffun-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboehm-s%2Ffun-php/lists"}