PHPackages                             graymatterlabs/experiment - 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. graymatterlabs/experiment

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

graymatterlabs/experiment
=========================

v0.3(2y ago)05[2 PRs](https://github.com/graymatterlabs/experiment/pulls)MITPHPPHP ^8.0

Since Aug 6Pushed 2y ago1 watchersCompare

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

READMEChangelog (7)Dependencies (5)Versions (10)Used By (0)

Simple yet highly extensible package for A/B testing in PHP
===========================================================

[](#simple-yet-highly-extensible-package-for-ab-testing-in-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a64dcfbf35940fae5e54da4ff0bb0d29197b80731046e568d8dc202f998f8f18/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f677261796d61747465726c6162732f6578706572696d656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graymatterlabs/experiment)[![Tests](https://github.com/graymatterlabs/experiment/actions/workflows/run-tests.yml/badge.svg?branch=master)](https://github.com/graymatterlabs/experiment/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/87b1fa378004d4371ef994ee11f010e9f0171fe86cdc3632f8884616b85fe35b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f677261796d61747465726c6162732f6578706572696d656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graymatterlabs/experiment)

This package makes no opinions on how you store your experiment data. Bring your own implementation of `GrayMatterLabs\Experiment\Contracts\Persistence` or use one of the provided implementations.

How you choose to implement your `GrayMatterLabs\Experiment\Contracts\Factory` will determine how you reference your experiments throughout the code. By default, there is an implementation provided that references experiments by their fully qualified class names.

Similarly, you may choose to and are encouraged to configure your experiments in a dynamic and/or data-backed way by instantiating them with data from any number of storage mechanisms as well as in any shape you see fit.

In general, this package attempts to not strictly enforce opinions as much as possible but rather provide an open-ended framework for A/B testing that minimizes complexity and overhead. You are encouraged to bring your own concrete implementations of the provided interfaces. You can, however, lean into the implementations provided for you.

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

[](#installation)

You can install the package via composer:

```
composer require graymatterlabs/experiment:^0.3
```

Usage
-----

[](#usage)

```
$manager = new Manager($persistence, $factory, $strategy);
$sample = new Sample();

$allocation = $manager->allocate($experiment, $sample);

if (! $allocation->isAllocated()) {
    // unable to allocate
}

if ($allocation->isVariant('TEST')) {
    // execute experimental feature
}

if ($allocation->wasRecentlyAllocated) {
    // the allocation is new
}
```

> Note: Usage of `GrayMatterLabs\Experiment\Persistence\SimpleCachePersistence` requires you satisfy the `Psr\SimpleCache\CacheInterface` interface. See graymatterlabs/simple-cache or bring your own implementation.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see the [Release Notes](../../releases) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Ryan Colson](https://github.com/ryancco)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.8% 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 ~49 days

Recently: every ~70 days

Total

7

Last Release

1084d ago

### Community

Maintainers

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

---

Top Contributors

[![ryancco](https://avatars.githubusercontent.com/u/20148569?v=4)](https://github.com/ryancco "ryancco (17 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")

---

Tags

ab testexperimentgraymatterlabs

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/graymatterlabs-experiment/health.svg)

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

###  Alternatives

[ajgarlag/feature-flag-bundle

Provides a feature flag mechanism

1417.8k](/packages/ajgarlag-feature-flag-bundle)

PHPackages © 2026

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