PHPackages                             innocraft/php-experiments - 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. innocraft/php-experiments

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

innocraft/php-experiments
=========================

PHP Experiments is a library that lets you run A/B and split tests

1.0.5(4mo ago)27244.8k↓23%8[1 issues](https://github.com/innocraft/php-experiments/issues)LGPL-3.0PHPPHP &gt;=5.5.9

Since Dec 20Pushed 4mo ago3 watchersCompare

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

READMEChangelog (6)Dependencies (1)Versions (8)Used By (0)

PHP Experiments is an A/B Test and Split Test library
=====================================================

[](#php-experiments-is-an-ab-test-and-split-test-library)

Code Status
-----------

[](#code-status)

[![Build Status](https://camo.githubusercontent.com/088ffd2a9d9824f42801ad3c775542bbac2807c96f6896cb7fff1ecd2bdb078d/68747470733a2f2f7472617669732d63692e6f72672f696e6e6f63726166742f7068702d6578706572696d656e74732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/innocraft/php-experiments)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b5cc88babe45245a88873dda0145bf24e30555a593b8dc3866fe6ccb3abe0d21/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f696e6e6f63726166742f7068702d6578706572696d656e74732e737667)](https://scrutinizer-ci.com/g/innocraft/php-experiments?branch=master)[![Code Coverage](https://camo.githubusercontent.com/3a0900c41488a28d384734b33dda0ed2d48f3c8a458c673f00b276c848f92823/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f696e6e6f63726166742f7068702d6578706572696d656e74732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/innocraft/php-experiments/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/c8c9a948c32162c0c51afebf13d5ba46afe7a0db91e665bb9bd31423d9580884/68747470733a2f2f706f7365722e707567782e6f72672f696e6e6f63726166742f7068702d6578706572696d656e74732f762f737461626c65)](https://packagist.org/packages/innocraft/php-experiments)[![License](https://camo.githubusercontent.com/7a6d00c7ca39bf7a8f9104f9648c15667cea14cfd1fab129a42acb4426ff4ab4/68747470733a2f2f706f7365722e707567782e6f72672f696e6e6f63726166742f7068702d6578706572696d656e74732f6c6963656e7365)](https://packagist.org/packages/innocraft/php-experiments)

Introduction
------------

[](#introduction)

PHP Experiments is built for [A/B and Split Testing for Matomo Analytics](https://www.ab-tests.net) but can be used in any PHP project. [Matomo (formerly Piwik)](https://matomo.org) is the leading open source web analytics platform used on over 1 million websites and apps in over 150 countries. [InnoCraft](https://www.innocraft.com) is the company of the makers of Matomo Analytics.

Features
--------

[](#features)

- Easily create and run A/B tests and split tests.
- Experiment traffic allocation: For example configure that only 80% of all users should participate in an experiment.
- Variation traffic allocation: For example allocate more traffic to some specific variations, giving other variations less traffic.
- When a user enters an experiment for the first time, a variation will be chosen randomly. On all subsequent requests the same variation will be activated.
- Possibility to force a specific variation instead of choosing it randomly.
- To ensure a user always gets to see the same variation, the name of the activated variation is stored in a cookie, a custom storage can be configured.
- Easy to use with plain arrays and easily extensible and customizable (custom storage, filters and variations can be defined).
- Tested with unit tests.
- No dependencies, lightweight, simple.

Example
-------

[](#example)

See [examples](examples) directory for various examples.

Running an A/B test might be as easy as:

```
$variations = [['name' => 'green'], ['name' => 'blue']];
$experiment = new Experiment('experimentName', $variations);
$activated = $experiment->getActivatedVariation();

echo $activated->getName();
```

Running a split URL test can be as easy as:

```
$variations = [
    ['name' => 'layout1', 'url' => '/layout1'],
    ['name' => 'layout2', 'url' => '/layout2']
];
$experiment = new Experiment('experimentName', $variations);
$activated = $experiment->getActivatedVariation();

// redirects to either URL or does nothing if the original version was activated
$activated->run();
```

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

[](#requirements)

- PHP 5.5.9 or greater

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

[](#installation)

To get the latest version, require the library using [Composer](https://getcomposer.org):

```
$ composer require innocraft/php-experiments
```

Instead, you may manually update your require block and run `composer update` if you so choose:

```
{
    "require": {
        "innocraft/php-experiments": "^1.0"
    }
}
```

License
-------

[](#license)

PHP Experiments is released under the LGPL v3 license, see [LICENSE](LICENSE).

Developer
---------

[](#developer)

### Docs generation

[](#docs-generation)

To update the documentation within the docs directory execute the following commands

- `cd docs`
- `composer install` (only needed once)
- `./generateDocs.sh`

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance74

Regular maintenance activity

Popularity45

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 78.1% 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 ~659 days

Recently: every ~823 days

Total

6

Last Release

140d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/875e7b7e4a44fe0022b5f57b768f7f5c9c4f87d69f16cc42ad4be9daebb67039?d=identicon)[innocraft](/maintainers/innocraft)

---

Top Contributors

[![tsteur](https://avatars.githubusercontent.com/u/273120?v=4)](https://github.com/tsteur "tsteur (25 commits)")[![AltamashShaikh](https://avatars.githubusercontent.com/u/14902277?v=4)](https://github.com/AltamashShaikh "AltamashShaikh (4 commits)")[![nickcFRU](https://avatars.githubusercontent.com/u/91071137?v=4)](https://github.com/nickcFRU "nickcFRU (1 commits)")[![sgiehl](https://avatars.githubusercontent.com/u/1579355?v=4)](https://github.com/sgiehl "sgiehl (1 commits)")[![snake14](https://avatars.githubusercontent.com/u/11394099?v=4)](https://github.com/snake14 "snake14 (1 commits)")

---

Tags

testingtestssplita-bexperiments

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/innocraft-php-experiments/health.svg)

```
[![Health](https://phpackages.com/badges/innocraft-php-experiments/health.svg)](https://phpackages.com/packages/innocraft-php-experiments)
```

###  Alternatives

[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)[dama/doctrine-test-bundle

Symfony bundle to isolate doctrine database tests and improve test performance

1.2k37.2M144](/packages/dama-doctrine-test-bundle)[typo3/testing-framework

The TYPO3 testing framework provides base classes for unit, functional and acceptance testing.

675.0M775](/packages/typo3-testing-framework)[lwc/kumite

A simple library for multivariate testing in web applications

2337.9k3](/packages/lwc-kumite)[jenssegers/ab

A server-side A/B testing tool for Laravel.

2955.6k](/packages/jenssegers-ab)[janmarek/mockista

Mockista is library for mocking, which I've written, because I find mocking in PHPUnit awful.

29221.0k28](/packages/janmarek-mockista)

PHPackages © 2026

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