{"id":37235329,"url":"https://github.com/php-slang/php-slang","last_synced_at":"2026-01-15T04:01:34.607Z","repository":{"id":57039964,"uuid":"69229453","full_name":"php-slang/php-slang","owner":"php-slang","description":"The place where PHP meets Functional Programming","archived":false,"fork":false,"pushed_at":"2018-05-21T09:52:46.000Z","size":189,"stargazers_count":105,"open_issues_count":23,"forks_count":10,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-07-21T09:58:22.313Z","etag":null,"topics":["either-monad","fp","functional-programming","future-monad","immutability","immutable-php","monad","optional","parallel-computing","parallelism","php"],"latest_commit_sha":null,"homepage":"http://phpslang.io","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-slang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-26T08:30:22.000Z","updated_at":"2024-05-18T12:48:43.000Z","dependencies_parsed_at":"2022-08-23T23:30:32.831Z","dependency_job_id":null,"html_url":"https://github.com/php-slang/php-slang","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/php-slang/php-slang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-slang%2Fphp-slang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-slang%2Fphp-slang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-slang%2Fphp-slang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-slang%2Fphp-slang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-slang","download_url":"https://codeload.github.com/php-slang/php-slang/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-slang%2Fphp-slang/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["either-monad","fp","functional-programming","future-monad","immutability","immutable-php","monad","optional","parallel-computing","parallelism","php"],"created_at":"2026-01-15T04:01:33.938Z","updated_at":"2026-01-15T04:01:34.589Z","avatar_url":"https://github.com/php-slang.png","language":"PHP","readme":"# PhpSlang \n[![Packagist](https://img.shields.io/packagist/v/php-slang/php-slang.svg)](https://packagist.org/packages/php-slang/php-slang)\n[![PHP from Packagist](https://img.shields.io/packagist/php-v/php-slang/php-slang.svg)](https://packagist.org/packages/php-slang/php-slang)\n[![Build Status](https://api.travis-ci.org/php-slang/php-slang.svg?branch=master\u0026style=flat-square)](https://travis-ci.org/php-slang/php-slang) \n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/php-slang/php-slang/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/php-slang/php-slang/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/php-slang/php-slang/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/php-slang/php-slang/?branch=master) \n[![Build Status](https://scrutinizer-ci.com/g/php-slang/php-slang/badges/build.png?b=master)](https://scrutinizer-ci.com/g/php-slang/php-slang/build-status/master)\n[![Packagist](https://img.shields.io/packagist/dt/php-slang/php-slang.svg)](https://packagist.org/packages/php-slang/php-slang)\n\n![PhpSlang](phpslang_logo.png)\n\nPhpSlang will help you to write purely functional code with PHP.\n\nPhpSlang is a PHP library aiming to fill the gaps between PHP and classical functional languages.\nIt provides constructs optimizing your work and letting you develop with a purely functional style.\n\n## More info\n\n[Official page](http://phpslang.io)\n\n[Documentation](https://php-slang.github.io/php-slang-docs/static/index.html)\n\n[Twitter](https://twitter.com/_phpslang)\n\n[Roadmap](https://trello.com/b/amNHaAgh/phpslang-roadmap)\n\n## Features\n\n - [x] [Option monad](https://php-slang.github.io/php-slang-docs/static/Usage/Essentials/Option.html)\n - [x] [Either monad](https://php-slang.github.io/php-slang-docs/static/Usage/Essentials/Either.html)\n - [x] [Copy trait](https://php-slang.github.io/php-slang-docs/static/Usage/Essentials/Copy_Trait.html)\n - [x] [Immutable List collection](https://php-slang.github.io/php-slang-docs/static/Usage/Immutable_Data_Structures/List.html)\n - [x] [Trampolines](https://php-slang.github.io/php-slang-docs/static/Usage/Trampolines.html)\n - [x] [Pattern matching](https://php-slang.github.io/php-slang-docs/static/Usage/Pattern_Matching.html)\n - [x] [Memoization](https://php-slang.github.io/php-slang-docs/static/Usage/Memoization.html)\n - [ ] [Immutable HashMap collections](https://php-slang.github.io/php-slang-docs/static/Usage/Immutable_Data_Structures/HashMap.html)\n - [x] [Immutable Set collections](https://php-slang.github.io/php-slang-docs/static/Usage/Immutable_Data_Structures/Set.html)\n - [ ] [Extractors](https://php-slang.github.io/php-slang-docs/static/Usage/Extractors.html)\n - [ ] [Try monad](https://php-slang.github.io/php-slang-docs/static/Usage/Essentials/Try.html)\n - [ ] [Future monad](https://php-slang.github.io/php-slang-docs/static/Usage/Essentials/Future.html)\n - [ ] [Parallel immutable List collection](https://php-slang.github.io/php-slang-docs/static/Usage/Immutable_Data_Structures/Parallel_Collections.html)\n - [ ] [Parallel immutable HashMap collection](https://php-slang.github.io/php-slang-docs/static/Usage/Immutable_Data_Structures/Parallel_Collections.html)\n - [ ] [Parallel immutable Set collection](https://php-slang.github.io/php-slang-docs/static/Usage/Immutable_Data_Structures/Parallel_Collections.html)\n - [ ] Traversable collections\n - [ ] Numeric type with infinite precision\n - [ ] Chainable\\pipe monad\n - [ ] Convenient enumeration\n\n## Example code\n\nWith a PhpSlang your code is going to look like that:\n```php\npublic function nonTrivialExampleFn(ParallelListCollection $mysteriousInput): float {\n  return $mysteriousInput\n    -\u003efilter(function ($elem) {\n      return $elem \u003e 10;\n    })\n    -\u003epartition(\n      function ($elem) {\n        return $elem \u003c=\u003e 20;\n      },\n      new Set([-1, 0, 1])\n    )\n    -\u003emap(function (ListCollection $bucket) {\n      return $bucket-\u003emax()-\u003egetOrElse(0.0);\n    })\n    -\u003eavg()\n    -\u003egetOrElse(0.0);\n}\n```\n\nOr that:\n\n```php\npublic function actionUpdateBook(string $bookId, Request $request): Response {\n  return $this\n    -\u003ebookUpdaterService\n    -\u003eupdateBook($bookId, $this-\u003ebookRequestTransformer-\u003etoInput($request), $this-\u003egetUser())\n    -\u003eleft(function(BookUpdateError $error) {\n      return Match::val($error)-\u003eof(\n        new TypeOf(BookNotFound::class, new Response(null, Response::HTTP_NOT_FOUND)),\n        new TypeOf(InvalidInput::class, new Response(null, Response::HTTP_BAD_REQUEST)),\n        new TypeOf(NotAuthorized::class, new Response(null, Response::HTTP_UNAUTHORIZED))\n      );\n    })\n    -\u003eright(function(BookInfo $bookInfo) {\n      return new Response($this-\u003ebookInfoTransformer-\u003etoJson($bookInfo), Response::HTTP_OK);\n    })\n    -\u003eget();\n}\n```\n\nWant to see more examples? [See documentation.](https://php-slang.github.io/php-slang-docs/static/index.html)\n\n## Contribution\n\n### TL;DR;\n\nJust feel free to post your pull requests on GitHub.\n\n### Contribution how to\n\n1. Fork this repository\n\n2. Clone your fork\n```\ngit clone git@github.com:php-slang/php-slang.git\n```\n\n2. Install dependencies\n```\ncomposer install --dev\n```\n\n3. Write some code\n\n4. Verify if it's fine\n```\n./ci/verify.sh\n```\n\n5. Push your pull request!\n\n## The MIT License (MIT)\n\nCopyright (c) 2018 Witold Adamus\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-slang%2Fphp-slang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-slang%2Fphp-slang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-slang%2Fphp-slang/lists"}