PHPackages                             marcosh/effector - 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. marcosh/effector

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

marcosh/effector
================

0.0.1(9y ago)15MITPHPPHP ^7.1

Since Apr 25Pushed 9y ago1 watchersCompare

[ Source](https://github.com/marcosh/effector)[ Packagist](https://packagist.org/packages/marcosh/effector)[ RSS](/packages/marcosh-effector/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (7)Versions (2)Used By (0)

Effector
========

[](#effector)

[![Build Status](https://camo.githubusercontent.com/4001197e562b68897cc90cf83bc97380aa01588c0fbe973474bcfdabcd44ebfe/68747470733a2f2f7472617669732d63692e6f72672f6d6172636f73682f6566666563746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/marcosh/effector)[![Latest Stable Version](https://camo.githubusercontent.com/d8444f1d0149c18bc4ee4e7e280c0cb44de96bcf79bed27945b467cdbc2237b1/68747470733a2f2f706f7365722e707567782e6f72672f6d6172636f73682f6566666563746f722f762f737461626c65)](https://packagist.org/packages/marcosh/effector)[![Code Climate](https://camo.githubusercontent.com/b4c5d8b34a0d5fdc386f0170bc15f35079b27ad90ab277ab69e3a012ff000f1e/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6d6172636f73682f6566666563746f722f6261646765732f6770612e737667)](https://codeclimate.com/github/marcosh/effector)[![Coverage Status](https://camo.githubusercontent.com/aa69c917ab9493f7fc92b43724ecb3eeabf5211c83963bb20b8d2191961fa63a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d6172636f73682f6566666563746f722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/marcosh/effector?branch=master)[![Code Quality](https://camo.githubusercontent.com/ed8d0935c891e70f13a62f4fc6916f27ed2182ff14ce9dc031f5598ad22305ed/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f67726164652f6666393563336535333630363439363338633631663238333462666664386232)](https://www.codacy.com/app/marcosh/effector/dashboard)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/12c431e25d03d60bc48fc5886fcc80fc34df62f1087373852353d602bb8484a0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6172636f73682f6566666563746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/marcosh/effector/?branch=master)

A Php library to write effect aware code.

In this library you will find a collection of classes, each one representing a single (side) effects. This allows you to write completely functional code treating effects as data, and delegating their execution to another component of your application.

You could find more details about the ideas beyond this approach [here](http://marcosh.github.io/post/2017/05/16/manage-effects.html).

Install
-------

[](#install)

Add this library to your dependencies using [Composer](https://getcomposer.org) with the command

```
composer require marcosh/effector
```

Usage
-----

[](#usage)

Every class contained in the `src/Effect` folder represents a single (side) effect. For example `Marcosh\Effector\Effect\Echo_` represents the operation of echoing a string, or `Marcosh\Effector\Effect|FileGetContents` represents the operation of reading a file.

You can create a new instance of an effects simply with

```
$effect = new Echo_();
```

Pay attention to the fact that nothing will actually happen at this moment (except for the creation of the new instance of the class).

To actually perform the effect described by the class, you will need to invoke it

```
$effect('hello!');
```

This will actually perform the effect and echo the string passed as argument.

### Compose effects

[](#compose-effects)

Representing effects as data is useful since you could pass them around, as input parameters or as return values of functions. Still if you had not the ability to create more complex effects from simple ones, they could be quite limiting.

Luckily, composing effects is pretty easy. To do that you could use the `Marcosh\Effector\Compose` class. This will receive several effects and pieces of logic and combine them in a single complex effect.

For example, if you have an effect that receives an HTTP request and an effect that emits an HTTP response, you could compose them to create a web application. This could be done as follows:

```
$websiteLogic = function (RequestInterface $request): ResponseInterface { ... }

$app = Compose::pieces(
    new ReceiveRequest(),
    $websiteLogic,
    new EmitResponse()
);
```

When you compose effects and pieces of logic, you have to be careful the each piece should return the input for the next one.

Examples
--------

[](#examples)

Several examples of possible usages and functionalities are provided in the `example` folder.

Run an example using

```
php example/ArgvEcho.php
```

or, if you are using Docker to obtain a `PHP 7.1` environment, you could use

```
docker run --rm -ti -v "$(pwd):/app" --workdir /app php:7.1-cli php example/ArgvEcho.php

```

The examples contained in `Http.php` and in `SerializeEffect.php` are web application, so you need a web server to try them. The easiest option is to use the built in PHP web server with

```
php -S localhost:8000 example/Http.php
```

or, if you are using Docker,

```
docker run --rm -ti -p 8000:8000 -v "$(pwd):/app" php:7.1-cli php -S 0.0.0.0:8000 /app/example/Http.php
```

and then navigate to [localhost:8000](http://localhost:8000) to see it working.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

3353d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2643972?v=4)[Marco Perone](/maintainers/marcosh)[@marcosh](https://github.com/marcosh)

---

Tags

effecteffectsfunctionalfunctional-programmingphpphp-7php-libraryside-effect

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/marcosh-effector/health.svg)

```
[![Health](https://phpackages.com/badges/marcosh-effector/health.svg)](https://phpackages.com/packages/marcosh-effector)
```

PHPackages © 2026

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