PHPackages                             rikbruil/php-redux - 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. rikbruil/php-redux

ActiveLibrary

rikbruil/php-redux
==================

Port of the Redux library for PHP and for fun

452625PHP

Since Jul 18Pushed 8y ago3 watchersCompare

[ Source](https://github.com/rikbruil/php-redux)[ Packagist](https://packagist.org/packages/rikbruil/php-redux)[ RSS](/packages/rikbruil-php-redux/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Redux for PHP
=============

[](#redux-for-php)

[![Build Status](https://camo.githubusercontent.com/4e54e1d62f79d1061595ffbb87e364f25423bd99e40e143e2875cb306f09c438/68747470733a2f2f7472617669732d63692e6f72672f72696b627275696c2f7068702d72656475782e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rikbruil/php-redux)[![Coverage Status](https://camo.githubusercontent.com/40a0d0d8eec3bc161e77c455c11e478a696f8b7f35f150076ce26a6cd2607ec5/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f72696b627275696c2f7068702d72656475782f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/rikbruil/php-redux?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/a5b3f001629c3798f5a4a55ea4c09b3a78eb16be34ae7c461fa3c234cf2087b7/68747470733a2f2f706f7365722e707567782e6f72672f72696b627275696c2f7068702d72656475782f762f737461626c65)](https://packagist.org/packages/rikbruil/php-redux)[![License](https://camo.githubusercontent.com/98d81636b2cacef5dc497ed58e95c49ce79d9feb0928b09337497a872f17c577/68747470733a2f2f706f7365722e707567782e6f72672f72696b627275696c2f7068702d72656475782f6c6963656e7365)](https://packagist.org/packages/rikbruil/php-redux)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b1a2979d0e6f51d1b47c8c5e67f51ba50b2e2f7d09240598765c5b5df25a123b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f72696b627275696c2f7068702d72656475782f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/rikbruil/php-redux/?branch=master)

Installation
------------

[](#installation)

```
composer require rikbruil/php-redux
```

Code example
------------

[](#code-example)

```
// Provide the initial state for the application
// This can be any type of value (preferably scalars)
$initialState = 0;

// Provide a reducer
// Reducers modify state based on a given action
// They follow the pattern: (state, action) => state
$reducer = function ($state, $action) {
    $type = $action['type'];

    if ($type === 'INCREMENT') {
        return $state + 1;
    }

    if ($type === 'DECREMENT') {
        return $state - 1;
    }

    return $state;
};

// Create the application store with the reducer in place
$store = new \Rb\Redux\Store::create($reducer, $initialState);

// Listeners are low-level functionality.
// They can be used to feed state into other (third-party) components.
// Listeners will fire when application state changes.
$listener = function (\Rb\Redux\StoreInterface $store) {
    $state = $store->getState();
    echo 'Counter: ' . $state . PHP_EOL;
};

// Optional: Middleware is allowed to replace the dispatch() method of the store.
// In this example it allows sending Promises that resolve to actions
$middleware = new \Rb\Redux\Middleware\Chain([
    new PromiseMiddleWare()
]);

// Middlewares need to be applied to the store
$middleware($store); // short-hand for: $middleware->apply($store);

// This will update global state to 1
$store->dispatch(['type' => 'INCREMENT']);

// We can safely dispatch promises due to the middleware
$deferred = new Deferred();
$promise = $deferred->promise();

// The listeners won't dispatch until the promise is resolved.
$store->dispatch($promise);

// Will still return 1
echo $store->getState() . PHP_EOL;

sleep(2);

// We will now resolve the promise, triggering the listeners
// This will decrement global state back to 0
$deferred->resolve(['type' => 'DECREMENT']);

// Will now return 0
echo $store->getState() . PHP_EOL;
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.9% of commits — single point of failure

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.

### Community

---

Top Contributors

[![rikbruil](https://avatars.githubusercontent.com/u/154175?v=4)](https://github.com/rikbruil "rikbruil (46 commits)")[![RafaelFontes](https://avatars.githubusercontent.com/u/27180?v=4)](https://github.com/RafaelFontes "RafaelFontes (1 commits)")

### Embed Badge

![Health badge](/badges/rikbruil-php-redux/health.svg)

```
[![Health](https://phpackages.com/badges/rikbruil-php-redux/health.svg)](https://phpackages.com/packages/rikbruil-php-redux)
```

PHPackages © 2026

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