# capacitor **Repository Path**: mirrors_robinvdvleuten/capacitor ## Basic Information - **Project Name**: capacitor - **Description**: Flux(ible) data flow for PHP apps. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-18 - **Last Updated**: 2026-10-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Capacitor Flux(ible) data flow for PHP apps. Flux Capacitor [![Build Status](https://travis-ci.org/robinvdvleuten/capacitor.svg?branch=master)](https://travis-ci.org/robinvdvleuten/capacitor) ## What is it? You've probably never heard of the ideas behind [Flux](https://facebook.github.io/react/) in PHP userland. It's an unidirectional data flow pattern used by Javascript applications to implement an user interface that responds to user actions. To us it looks like an enhanced message bus with event sourcing capabilities and is definitely something we can use in our PHP applications. ## Installation The recommended way to install the library is through [Composer](https://getcomposer.org/); ```bash composer require rvdv/capacitor ``` ## Usage - at a glance The most simple implementation of Capacitor is the message bus pattern where multiple listeners can subscribe to dispatched messages; ```php use Capacitor\Capacitor; $bus = new Capacitor(); $unsubscribe = $bus->subscribe(function ($message) { var_dump($message); // Outputs "message" return $message; }); $bus->subscribe(function ($message) { var_dump($message); // Outputs "message"; "another message" return $message; }); $bus('message'); $unsubscribe(); $bus('another message'); ``` For this and other implementations, take a look at the `/examples` directory. ## Tests To run the test suite, you need install the dependencies via composer, then run PHPUnit. ```bash composer install php vendor/bin/phpunit ``` ## License MIT © [Robin van der Vleuten](https://www.robinvdvleuten.nl)