PHPackages                             dmt-software/ab-middleware - 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. dmt-software/ab-middleware

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

dmt-software/ab-middleware
==========================

ab testing middleware compatible with psr

0.0.10(2mo ago)05.8k↓16.7%[1 PRs](https://github.com/dmt-software/ab-middleware/pulls)1MITPHPPHP ^8.3CI passing

Since Oct 29Pushed 7mo ago2 watchersCompare

[ Source](https://github.com/dmt-software/ab-middleware)[ Packagist](https://packagist.org/packages/dmt-software/ab-middleware)[ RSS](/packages/dmt-software-ab-middleware/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (16)Versions (12)Used By (1)

PSR-15 ab testing middleware
============================

[](#psr-15-ab-testing-middleware)

This PSR-15 middleware allows you to do A/B testing on your application.

Cookies are used to keep track of a randomly generated user-id. Based on this cookie, a variant is selected for an experiment.

The Twig helper can be used to conditionally render the experiment template variants.

Although more than one experiment can be defined, only one experiment is supposed to be active at a time.

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

[](#installation)

```
composer require dmt-software/ab-middleware
```

Usage
-----

[](#usage)

```
use DMT\AbMiddleware\AbService;
use DMT\AbMiddleware\AbPsrMiddleware;

// define your experiments
$experiments = [
    'active-experiment' => [
        'variant-1' => 0.3,
        'variant-2' => 0.3,
        'control' => 0.4,
    ],
    'old-experiment' => [
        'variant-1' => 0.3,
        'variant-2' => 0.3,
        'control' => 0.4,
    ],
];

// instantiate the service
$service = new AbService($experiments);

// instantiate the middleware
$abMiddleware = new AbPsrMiddleware($service, 'ab-uid-cookie-name');

// add the middleware to your middleware stack
```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance74

Regular maintenance activity

Popularity23

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72% 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 ~55 days

Recently: every ~71 days

Total

10

Last Release

69d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec6b7fbb4d231b5c2c76348cf3a13ec5e82c64a1826142f6ec0db1cf15db2873?d=identicon)[proggeler](/maintainers/proggeler)

![](https://www.gravatar.com/avatar/ea1df8d4eb476756f31e2c698e8b2c161c8be1b8482091f930abbddfd8d2fc52?d=identicon)[lingonl](/maintainers/lingonl)

---

Top Contributors

[![lingonl](https://avatars.githubusercontent.com/u/3777294?v=4)](https://github.com/lingonl "lingonl (18 commits)")[![KirosML](https://avatars.githubusercontent.com/u/123894927?v=4)](https://github.com/KirosML "KirosML (7 commits)")

---

Tags

ab-testingpsr-15

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/dmt-software-ab-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/dmt-software-ab-middleware/health.svg)](https://phpackages.com/packages/dmt-software-ab-middleware)
```

###  Alternatives

[spatie/laravel-analytics

A Laravel package to retrieve Google Analytics data.

3.2k5.7M57](/packages/spatie-laravel-analytics)[psr7-sessions/storageless

Storageless PSR-7 Session support

652373.0k8](/packages/psr7-sessions-storageless)[mcp/sdk

Model Context Protocol SDK for Client and Server applications in PHP

1.4k423.9k30](/packages/mcp-sdk)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[markstory/asset_compress

An asset compression plugin for CakePHP. Provides file concatenation and a flexible filter system for preprocessing and minification.

3761.0M11](/packages/markstory-asset-compress)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

73142.3k25](/packages/jaxon-php-jaxon-core)

PHPackages © 2026

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