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

AbandonedArchivedLibrary

orchid/experiment
=================

AB tests for Laravel

2.4(3y ago)56120.0k↓100%5MITPHP

Since Nov 29Pushed 3y ago8 watchersCompare

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

READMEChangelog (7)Dependencies (4)Versions (8)Used By (0)

> **Warning**
>
> With the release of Laravel 10, there is an official [Pennant](https://laravel.com/docs/10.x/pennant) package that can replace the current one. So consider upgrading to it.

Experiment
==========

[](#experiment)

[![tests](https://github.com/tabuna/experiment/workflows/run-tests/badge.svg)](https://github.com/tabuna/experiment/workflows/run-tests/badge.svg)[![](https://camo.githubusercontent.com/06c00749281545663aacd5bd5356ab918f7d971a005dedf84e6b0f9e2df2e271/68747470733a2f2f7374796c6563692e696f2f7265706f732f3135393733303034332f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/159730043)[![](https://camo.githubusercontent.com/77b36ddccffd2dee19adf2d96f411eaf6d2d02b9e8dcab13c363815a9ce4db87/68747470733a2f2f636f6465636f762e696f2f67682f746162756e612f6578706572696d656e742f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/tabuna/experiment)[![](https://camo.githubusercontent.com/89bbead42ddcc020d087931f551b544fb460047cd60b3e0fb7331906a42d077e/68747470733a2f2f706f7365722e707567782e6f72672f6f72636869642f6578706572696d656e742f762f737461626c65)](https://packagist.org/packages/orchid/experiment)[![](https://camo.githubusercontent.com/d9e9070ae9c21b72a1572f1b5e134039332e47a2679772bed7d79c51cb4428e3/68747470733a2f2f706f7365722e707567782e6f72672f6f72636869642f6578706572696d656e742f646f776e6c6f616473)](https://packagist.org/packages/orchid/experiment)[![](https://camo.githubusercontent.com/b0fb49ce4391703c129cb676ff9c99ccf3cb67fc0998c2566c56fc7127602a62/68747470733a2f2f706f7365722e707567782e6f72672f6f72636869642f6578706572696d656e742f6c6963656e7365)](https://packagist.org/packages/orchid/experiment)

An A/B Testing suite for Laravel, which allows multiple experiments.

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

[](#installation)

Download using Composer:

```
$ composer require orchid/experiment
```

### Base Usage

[](#base-usage)

Your cache driver will be used by default.

```
use Orchid\Experiment\Experiment;

$experiment = new Experiment();

// Distribution
$ab = $experiment->start([
    'A' => 1,
    'B' => 1,
]); // A or B
```

The experiment is transmitted in an array, where the keys are the names, and the values are the required ratios. For example, if you specify two values containing A -&gt; 50 and B -&gt; 100, there will be 50 users with the value A, then there will be 100 users with the value B. It allows us to define how the testing will be distributed clearly.

```
use Orchid\Experiment\Experiment;
use Illuminate\Support\Facades\Cache;

$storage = Cache::store('redis');
$experiment = new Experiment('my-key', $storage);

$ab = $experiment->start([
    'A' => 50,
    'B' => 100,
]); // A or B
```

You can also install via your request:

```
http:://example.com?my-key=A
```

### Cookie

[](#cookie)

I recommend putting this on middleware and immediately install a cookie using.

```
namespace App\Http\Middleware;

use Closure;
use Orchid\Experiment\Experiment;

class Experiments
{

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     *
     * @return mixed
     * @throws \Exception
     */
    public function handle($request, Closure $next)
    {
        $experiment = new Experiment('AB');

        $experiment->startAndSaveCookie([
            'A' => 50,
            'B' => 50,
        ]);

        return $next($request);
    }
}
```

It allows you to transfer data to Google analytics and similar services using javascript.

```
alert( document.cookie );
```

Laravel encrypts all cookies by default, so do not forget to specify your key in the exceptions `app/Http/Middleware/EncryptCookies.php`:

```
namespace App\Http\Middleware;

use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;

class EncryptCookies extends Middleware
{
    /**
     * The names of the cookies that should not be encrypted.
     *
     * @var array
     */
    protected $except = [
        'AB'
    ];
}
```

### Blade

[](#blade)

If you want to use the blade, you still must install the middleware after this call is as example:

```
@experiment('my-key', 'A')
    Click me
@else
    Push me
@endexperiment
```

#### Tests

[](#tests)

```
php vendor/bin/phpunit --coverage-html ./logs/coverage ./tests
```

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 98% 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 ~216 days

Recently: every ~250 days

Total

7

Last Release

1418d ago

Major Versions

1.1 → 2.02019-09-23

PHP version history (2 changes)1.0PHP ^7.1.3

2.2PHP ^7.2.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/3c47797b11041f37c2eec74b09bc6619c8997467d690797ebad0e6ab7cb232b7?d=identicon)[tabuna](/maintainers/tabuna)

---

Top Contributors

[![tabuna](https://avatars.githubusercontent.com/u/5102591?v=4)](https://github.com/tabuna "tabuna (48 commits)")[![Dravenshorst](https://avatars.githubusercontent.com/u/10696434?v=4)](https://github.com/Dravenshorst "Dravenshorst (1 commits)")

---

Tags

ab-testingabtestabtestinglaravellaravel-framework

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[namu/wirechat

A Laravel Livewire messaging app for teams with private chats and group conversations.

54324.5k](/packages/namu-wirechat)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)

PHPackages © 2026

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