PHPackages                             andreekeberg/abby - 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. andreekeberg/abby

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

andreekeberg/abby
=================

🙋‍♀️ Minimal A/B Testing Library

1.1.1(6y ago)3210.3k↓31%[3 issues](https://github.com/andreekeberg/abby/issues)MITPHPPHP &gt;=5.4.0

Since Apr 28Pushed 5y ago3 watchersCompare

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

READMEChangelog (3)DependenciesVersions (4)Used By (0)

🙋🏽‍♀️ Abby
==========

[](#‍️-abby)

[![Latest Stable Version](https://camo.githubusercontent.com/46ff05f811c4edef527e870e5f9deee29a03406ff37d465c45865b938d5e851d/68747470733a2f2f706f7365722e707567782e6f72672f616e647265656b65626572672f616262792f762f737461626c65)](https://packagist.org/packages/andreekeberg/abby) [![Total Downloads](https://camo.githubusercontent.com/5e7f460efadccb18cd036222366c7cbecb88e588d2b3a203cf4f68cbf4977473/68747470733a2f2f706f7365722e707567782e6f72672f616e647265656b65626572672f616262792f646f776e6c6f616473)](https://packagist.org/packages/andreekeberg/abby) [![License](https://camo.githubusercontent.com/3dfa3c4ad332e043578ca6700efcaa5153a80570cbf7dd908defac4b26c6dfb3/68747470733a2f2f706f7365722e707567782e6f72672f616e647265656b65626572672f616262792f6c6963656e7365)](https://packagist.org/packages/andreekeberg/abby)

Abby is a simple, but powerful PHP A/B testing library.

The library lets you easily setup tests (**experiments**), their control and variation **groups**, track your **users**, get detailed statistics (like recommended sample sizes, and determining the confidence of your **results**), including whether an experiment has achieved **statistical significance**.

The winner (and confidence) is detemined using [Bayesian statistics](https://en.wikipedia.org/wiki/Bayesian_statistics), calculating the [p-value](https://en.wikipedia.org/wiki/P-value) of your results to check if the [null hypothesis](http://en.wikipedia.org/wiki/Null_hypothesis) can be rejected. An accompanying minimum [sample size](https://en.wikipedia.org/wiki/Sample_size_determination) is also calculated using a [two-tailed test](https://en.wikipedia.org/wiki/One-_and_two-tailed_tests) to control the [false discovery rate](https://en.wikipedia.org/wiki/False_discovery_rate).

Abby is dependency free, and completely database agnostic, meaning it simply works with data you provide it with, and exposes a variety of methods for you to store the result in your own storage of choice.

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

[](#requirements)

- PHP 5.4.0 or higher

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

[](#installation)

```
composer require andreekeberg/abby

```

Basic usage
-----------

[](#basic-usage)

### Tracking a user

[](#tracking-a-user)

```
// Setup a new Token instance
$token = new Abby\Token();

// If we can't find an existing token cookie, generate one and set tracking cookie
if (!$token->getValue()) {
    $token->generate()->setCookie();
}

// Setup a User instance
$user = new Abby\User();

// Associate the token with our user
$user->setToken($token);
```

### Adding existing user experiments to a user instance

[](#adding-existing-user-experiments-to-a-user-instance)

```
// List of experiments associated with a tracking token
$data = [
    [
        'id' => 1,
        'group' => 1,
        'viewed' => true,
        'converted' => false
    ]
];

// Loop through users existing experiments and add them to our user instance
foreach ($data as $item) {
    // Setup experiment instance based on an existing experiment
    $experiment = new Abby\Experiment([
        'id' => $item['id']
    ]);

    // Setup a group instance based on stored data
    $group = new Abby\Group([
        'type' => $item['group']
    ]);

    // Add the experiment (including their group, and whether they have viewed and converted)
    $user->addExperiment($experiment, $group, $item['viewed'], $item['converted']);
}
```

### Including the using in new experiments

[](#including-the-using-in-new-experiments)

```
// Experiment data
$data = [
    'id' => 2
];

// Make sure the experiment isn't already in the users list
if (!$user->hasExperiment($data['id'])) {
    // Setup a new experiment instance
    $experiment = new Abby\Experiment([
        'id' => $data['id']
    ]);

    // Assign the user to either control or variation in the experiment
    $group = $user->assignGroup($experiment);

    // Add the experiment (including assigned group) to our user instance
    $user->addExperiment($experiment, $group);
}

// Getting updated user experiment list
$user->getExperiments();

// Store updated experiment list for our user
```

### Delivering a custom experience based on group participation

[](#delivering-a-custom-experience-based-on-group-participation)

```
// Experiment data
$data = [
    'id' => 1
];

// Record a view for the experiment in question
$user->setViewed($data['id']);

// If the user is part of the variation group
if ($user->inVariation($data['id'])) {
    // Apply a custom class to an element, load a script, etc.
}
```

### Defining a user conversion in an experiment

[](#defining-a-user-conversion-in-an-experiment)

```
// Experiment data
$data = [
    'id' => 1
];

// On a custom goal, check if user has viewed the experiment and define a conversion
if ($user->hasViewed($data['id'])) {
    $user->setConverted($data['id']);
}

// Getting updated user experiment data
$user->getExperiments();

// Store updated data for our user
```

### Getting experiment results

[](#getting-experiment-results)

```
// Setup experiment instance with stored results
$experiment = new Abby\Experiment([
    'groups' => [
        [
            'name' => 'Control',
            'views' => 3000,
            'conversions' => 300
        ],
        [
            'name' => 'Variation',
            'views' => 3000,
            'conversions' => 364
        ]
    ]
]);

// Retrieve the results
$result = $experiment->getResult();

// Get the winner
$winner = $result->getWinner();

/**
 * Get whether we can be confident of the result (even if we haven't
 * reached the minimum number of views for each variant)
 */

$confident = $result->isConfident();

/**
 * Get the minimum sample size (number of views) required for each group to
 * reach statistical significance, given the control groups current conversion
 * rate (based on the configured minimumDetectableEffect)
 */

$minimum = $result->getMinimumSampleSize();

/**
 * Get whether the results are statistically significant
 */

$significant = $result->isSignificant();

/**
 * Get complete experiment result
 */

$summary = $result->getAll();
```

Documentation
-------------

[](#documentation)

- [Experiment](docs/Experiment.md)
- [Token](docs/Token.md)
- [User](docs/User.md)
- [Group](docs/Group.md)
- [Result](docs/Result.md)

Contributing
------------

[](#contributing)

Read the [contribution guidelines](CONTRIBUTING.md).

Changelog
---------

[](#changelog)

Refer to the [changelog](CHANGELOG.md) for a full history of the project.

License
-------

[](#license)

Abby is licensed under the [MIT license](LICENSE).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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 ~11 days

Total

3

Last Release

2190d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/86bc1ee1c801495796569fefa0c1275d88542a5d74d5ddf04c4851e88351fa20?d=identicon)[andreekeberg](/maintainers/andreekeberg)

---

Tags

ab-testingbayesian-statisticsconfidenceconversion-rateconversion-trackingconversionsp-valuephp-libraryprobabilitysample-sizesample-size-calculationsequentialsignificancesignificance-testingsplit-testingstatistical-significancestatisticstwo-sample-statisticsz-scorestatisticssplit testingsequentialprobabilityconversionsab-testingsignificancep-valuez-scoresample-sizesample-size-calculationconversion-rateconversion-trackingconfidencestatistical-significancesignificance-testingtwo-sample-statisticsbayesian-statistics

### Embed Badge

![Health badge](/badges/andreekeberg-abby/health.svg)

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

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[markrogoyski/math-php

Math Library for PHP. Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra

2.4k7.1M40](/packages/markrogoyski-math-php)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

78768.9M1.5k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

66766.6M1.1k](/packages/phpstan-phpstan-doctrine)

PHPackages © 2026

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