PHPackages                             offdev/bandit - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. offdev/bandit

ActiveLibrary[Testing &amp; Quality](/categories/testing)

offdev/bandit
=============

An A/B/x testing algorithm written in PHP by implementing the solution to the multi armed bandit problem

1.0.0(9y ago)1710.6k1Apache License 2.0PHPPHP &gt;=7

Since Aug 13Pushed 5y ago1 watchersCompare

[ Source](https://github.com/offdev/bandit)[ Packagist](https://packagist.org/packages/offdev/bandit)[ Docs](https://github.com/offdev/bandit)[ RSS](/packages/offdev-bandit/feed)WikiDiscussions master Synced 1mo ago

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

Offdev/Bandit
=============

[](#offdevbandit)

An A/B/x testing algorithm written in PHP by implementing the solution to the multi armed bandit problem

[![Latest Stable Version](https://camo.githubusercontent.com/da966abdba88f84067f6ce9c120a1ff9bc47d1e1b665cb282cc18e4c37c20a48/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f6f66666465762f62616e6469742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/offdev/bandit)[![Minimum PHP Version](https://camo.githubusercontent.com/90eed33e7df559b70b174e97d37a4907946803c7ab691640166d2518d8cd2118/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e302d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://php.net/)[![Build Status](https://camo.githubusercontent.com/7da8e5fda6724ef7807a1313be61fdd8cc590cbaf76b696d6b613d29e82da413/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6f66666465762f62616e6469742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/offdev/bandit)[![License](https://camo.githubusercontent.com/728d5b95aba796691cedaf25c45966d45a78d985d916db638cc9d6211ae9b895/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f66666465762f62616e6469742e737667)](https://www.apache.org/licenses/LICENSE-2.0)

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4
- Composer

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

[](#installation)

```
$ composer require offdev/bandit
```

General Usage
-------------

[](#general-usage)

First, you need to set up a machine, and its possible levers. A lever might have already been pulled a few times, and some levers may also have rewarded the lucky person which pulled it, so adjust those numbers accordingly. Example:

```
use Offdev\Bandit\Lever;
use Offdev\Bandit\Machine;

$machine = new Machine(
    new Lever('first-lever', 123, 1),
    new Lever('second-lever', 108, 3),
    new Lever('third-lever', 115, 0),
);
```

Now you need a strategy to solve your problem. See [this link](https://en.wikipedia.org/wiki/Multi-armed_bandit#Bandit_strategies) for more information about strategies, and have a look at the example ones I have included in `src/php/Strategies`. Example:

```
use Offdev\Bandit\Strategies\EpsilonGreedy;

$strategy = new EpsilonGreedy();
$winningLever = $strategy->solve($machine);
```

It is as simple as that :)

TODO
----

[](#todo)

Add more docs :)

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 67.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.

###  Release Activity

Cadence

Every ~94 days

Total

3

Last Release

3377d ago

Major Versions

0.1.1 → 1.0.02017-02-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/49cd7805c119ee766fe6f126551fbf2e03c6145c038a7d89ec007b0a019dd809?d=identicon)[offdev](/maintainers/offdev)

---

Top Contributors

[![offdev](https://avatars.githubusercontent.com/u/7830782?v=4)](https://github.com/offdev "offdev (19 commits)")[![pascal-severin](https://avatars.githubusercontent.com/u/85936233?v=4)](https://github.com/pascal-severin "pascal-severin (9 commits)")

---

Tags

testingtestmultibanditoffdevarmed

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/offdev-bandit/health.svg)

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

###  Alternatives

[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[php-mock/php-mock

PHP-Mock can mock built-in PHP functions (e.g. time()). PHP-Mock relies on PHP's namespace fallback policy. No further extension is needed.

36918.1M98](/packages/php-mock-php-mock)[brain/monkey

Mocking utility for PHP functions and WordPress plugin API

33812.5M350](/packages/brain-monkey)[ta-tikoma/phpunit-architecture-test

Methods for testing application architecture

10745.9M13](/packages/ta-tikoma-phpunit-architecture-test)[php-mock/php-mock-phpunit

Mock built-in PHP functions (e.g. time()) with PHPUnit. This package relies on PHP's namespace fallback policy. No further extension is needed.

1718.2M399](/packages/php-mock-php-mock-phpunit)[fr3d/swagger-assertions

Test your API requests and responses against your swagger definition

138850.9k5](/packages/fr3d-swagger-assertions)

PHPackages © 2026

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