{"id":15025322,"url":"https://github.com/marcosh/effector","last_synced_at":"2026-01-27T20:09:04.555Z","repository":{"id":62523861,"uuid":"84422203","full_name":"marcosh/effector","owner":"marcosh","description":"A Php library to write effect aware code.","archived":false,"fork":false,"pushed_at":"2017-05-24T06:15:24.000Z","size":67,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-13T06:57:17.134Z","etag":null,"topics":["effect","effects","functional","functional-programming","php","php-7","php-library","side-effect"],"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/marcosh.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":"2017-03-09T09:16:50.000Z","updated_at":"2021-10-15T15:28:23.000Z","dependencies_parsed_at":"2022-11-02T10:45:33.702Z","dependency_job_id":null,"html_url":"https://github.com/marcosh/effector","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/marcosh/effector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosh%2Feffector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosh%2Feffector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosh%2Feffector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosh%2Feffector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcosh","download_url":"https://codeload.github.com/marcosh/effector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosh%2Feffector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28820352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T18:44:20.126Z","status":"ssl_error","status_checked_at":"2026-01-27T18:44:09.161Z","response_time":168,"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":["effect","effects","functional","functional-programming","php","php-7","php-library","side-effect"],"created_at":"2024-09-24T20:02:04.289Z","updated_at":"2026-01-27T20:09:04.540Z","avatar_url":"https://github.com/marcosh.png","language":"PHP","readme":"# Effector\n\n[![Build Status](https://travis-ci.org/marcosh/effector.svg?branch=master)](https://travis-ci.org/marcosh/effector)\n[![Latest Stable Version](https://poser.pugx.org/marcosh/effector/v/stable)](https://packagist.org/packages/marcosh/effector)\n[![Code Climate](https://codeclimate.com/github/marcosh/effector/badges/gpa.svg)](https://codeclimate.com/github/marcosh/effector)\n[![Coverage Status](https://coveralls.io/repos/github/marcosh/effector/badge.svg?branch=master)](https://coveralls.io/github/marcosh/effector?branch=master)\n[![Code Quality](https://api.codacy.com/project/badge/grade/ff95c3e5360649638c61f2834bffd8b2)](https://www.codacy.com/app/marcosh/effector/dashboard)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/marcosh/effector/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/marcosh/effector/?branch=master)\n\nA Php library to write effect aware code.\n\nIn this library you will find a collection of classes, each one representing a single (side) effects.\nThis allows you to write completely functional code treating effects as data, and delegating their execution\nto another component of your application.\n\nYou could find more details about the ideas beyond this approach [here](http://marcosh.github.io/post/2017/05/16/manage-effects.html).\n\n## Install\n\nAdd this library to your dependencies using [Composer](https://getcomposer.org) with the command\n\n```bash\ncomposer require marcosh/effector\n```\n\n## Usage\n\nEvery class contained in the `src/Effect` folder represents a single (side) effect.\nFor example `Marcosh\\Effector\\Effect\\Echo_` represents the operation of echoing a string,\nor `Marcosh\\Effector\\Effect|FileGetContents` represents the operation of reading a file.\n\nYou can create a new instance of an effects simply with\n\n```php\n$effect = new Echo_();\n```\n\nPay attention to the fact that nothing will actually happen at this moment\n(except for the creation of the new instance of the class).\n\nTo actually perform the effect described by the class, you will need to invoke it\n\n```php\n$effect('hello!');\n```\n\nThis will actually perform the effect and echo the string passed as argument.\n\n### Compose effects\n\nRepresenting effects as data is useful since you could pass them around, as input parameters\nor as return values of functions. Still if you had not the ability to create more complex effects\nfrom simple ones, they could be quite limiting.\n\nLuckily, composing effects is pretty easy. To do that you could use the `Marcosh\\Effector\\Compose` class.\nThis will receive several effects and pieces of logic and combine them in a single complex effect.\n\nFor example, if you have an effect that receives an HTTP request and an effect that emits an HTTP response,\nyou could compose them to create a web application. This could be done as follows:\n\n```php\n$websiteLogic = function (RequestInterface $request): ResponseInterface { ... }\n\n$app = Compose::pieces(\n    new ReceiveRequest(),\n    $websiteLogic,\n    new EmitResponse()\n);\n```\n\nWhen you compose effects and pieces of logic, you have to be careful the each piece should return\nthe input for the next one.\n\n## Examples\n\nSeveral examples of possible usages and functionalities are provided in the `example` folder.\n\nRun an example using\n\n```bash\nphp example/ArgvEcho.php\n```\n\nor, if you are using Docker to obtain a `PHP 7.1` environment, you could use\n\n```\ndocker run --rm -ti -v \"$(pwd):/app\" --workdir /app php:7.1-cli php example/ArgvEcho.php\n```\n\nThe examples contained in `Http.php` and in `SerializeEffect.php` are web application, so you need a web server to try them.\nThe easiest option is to use the built in PHP web server with\n\n```bash\nphp -S localhost:8000 example/Http.php\n```\n\nor, if you are using Docker,\n\n```bash\ndocker run --rm -ti -p 8000:8000 -v \"$(pwd):/app\" php:7.1-cli php -S 0.0.0.0:8000 /app/example/Http.php\n```\n\nand then navigate to [localhost:8000](http://localhost:8000) to see it working.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcosh%2Feffector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcosh%2Feffector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcosh%2Feffector/lists"}