PHPackages                             abrouter/laravel-abtest - 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. abrouter/laravel-abtest

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

abrouter/laravel-abtest
=======================

AbrLaravelClient :construction\_worker\_woman: is a PHP client for laravel to run ab-tests via ABRouter.

0.36.0(1y ago)10823.0k↓31.2%6LGPL-3.0-or-laterPHPPHP ^7.4 || ^8.0

Since Oct 7Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/abrouter/laravel-abtest)[ Packagist](https://packagist.org/packages/abrouter/laravel-abtest)[ RSS](/packages/abrouter-laravel-abtest/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (2)Versions (37)Used By (0)

ABRouter Laravel A/B Tests | Split Tests
========================================

[](#abrouter-laravel-ab-tests--split-tests)

ABRouter AB Test 👷‍♀️ is a simple package for base library to run A/B tests via [ABRouter (open-source)](https://abrouter.com) with Laravel. You can find base PHP library in

You're welcome to [visit the docs](https://docs.abrouter.com/docs/intro/).

[Learn how to deploy ABRouter on your server](https://github.com/abrouter/abrouter).

What is the ABRouter service ?
==============================

[](#what-is-the-abrouter-service-)

[ABRouter](https://abrouter.com) is the open-source product to manage experiments(A/B split tests). The service provides easy to manage dashboard to keep experiments under control. You can create experiments, branches and set up a percentage for every branch. Then, when you're running an ab-test on PHP you will receive a perfect branch-wise response that following the rules, that you set up.

Providing feature flags(feature toggles) Available for free and open-source.

You can find the ABRouter product source code by the following link:

Features
--------

[](#features)

🛠 A/B Tests

🛠 Feature flags

🛠 Built-in statistics

🛠 Incredible UI to manage it

🛠 Parallel running (non-blocking A/B tests running)

Prepare your first A/B test
---------------------------

[](#prepare-your-first-ab-test)

Besides of the installing this package you need to have an account on [ABRouter](https://abrouter.com). Your token and experiment id will be also there. Feel free to read step by step instruction [Impelementing A/B tests on Laravel](https://abrouter.com/en/laravel-ab-tests)

📦 Install
---------

[](#package-install)

Via composer

```
$ composer require abrouter/laravel-abtest
```

Setting service provider
------------------------

[](#setting-service-provider)

This package provide auto discovery for service provider

If Laravel package auto-discovery is disabled, add service providers manually to /config/app.php. There are service provider you must add:

```
\Abrouter\LaravelClient\Providers\AbrouterServiceProvider::class

```

### Publish client configuration:

[](#publish-client-configuration)

```
php artisan vendor:publish --tag=abrouter
```

### Configure ABRouter client:

[](#configure-abrouter-client)

Put your ABRouter token in /config/abrouter.php. You can find this token in [ABRouter dashboard](https://abrouter.com/en/board).

```
use Abrouter\LaravelClient\Bridge\KvStorage;
use Abrouter\LaravelClient\Bridge\ParallelRunning\TaskManager;

return [
    'token' => '14da89de1713a74c1ed50aafaff18c24bf372a9913e67e6a7a915def3332a97c9c9ecbe2cd6d3047',
    'host' => 'https://abrouter.com',
    'parallelRunning' => [
        'enabled' => true, //parallel running, enabled by default. See next section.
        'taskManager' => TaskManager::class,
    ],
    'kvStorage' => KvStorage::class
];
```

### Configure Parallel running

[](#configure-parallel-running)

Parallel running is a feature that allows you to run A/B tests asynchronously. It requires ready-to-use Laravel cache (probably by Redis).

This feature enables caching of experiment branches to run the experiment locally, then using Laravel built-in queues to sync the data with ABRouter server. Please make sure, your supervisor config, queues and caching storage is enabled in Laravel to use.

Parallel running allows to run your A/B tests without blocking. Additionally, you can configure it on your own.

🚀 Running A/B tests
-------------------

[](#rocket-running-ab-tests)

```
use Abrouter\Client\Client;

class ExampleController
{
    public function __invoke(Client $client)
    {
        $userId = auth()->user()->id;
        $buttonColor = $client->experiments()->run($userId, 'button_color');
        return view('button', [
            'color' => $buttonColor->getBranchId(),
        ]);
    }
}
```

🚀 Running feature flags
-----------------------

[](#rocket-running-feature-flags)

```
use Abrouter\Client\Client;

class ExampleController
{
    public function __invoke(Client $client)
    {
        $isEnabledButton = $client->featureFlags()->run('enabled_button_feature_flag');

        return view('featureFlags', [
            'enabledButtonFeatureFlag' => $isEnabledButton,
        ]);
    }
}
```

🚀 Sending the stats
-------------------

[](#rocket-sending-the-stats)

```
use Abrouter\Client\Client;
use Abrouter\Client\Builders\StatEventBuilder;

class ExampleController
{
    public function __invoke(Client $client, StatEventBuilder $statEventBuilder)
    {
        $userId = auth()->user()->id;
        //sending button_click event as button_click+1
        $client->statistics()->sendEvent(
            $eventBuilder
                ->incremental()
                ->event('button_click')
                ->setUserId($userId)
                ->build()
        );

        //sending purchase event with purchase amount (+30)
        $client->statistics()->sendEvent(
            $eventBuilder
                ->summarize()
                ->event('purchase')
                ->setValue(30)
                ->setUserId($userId)
                ->build()
        );
    }
}
```

For additional details of sending events please see StatEventBuilder class.

### Managing UI

[](#managing-ui)

You can create an experiment/feature flags and set up statistics and get your token and id of experiment on [ABRouter](https://abrouter.com) or just read the [docs](https://abrouter.com/en/docs).

Example
-------

[](#example)

You can get an dockerized usage example by the following link: ()

🔧 Contributing
--------------

[](#wrench-contributing)

Please feel free to fork and sending Pull Requests. This project follows [Semantic Versioning 2](http://semver.org) and [PSR-2](http://www.php-fig.org/psr/psr-2/).

📄 License
---------

[](#page_facing_up-license)

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

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance72

Regular maintenance activity

Popularity41

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.4% 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 ~37 days

Recently: every ~243 days

Total

36

Last Release

426d ago

PHP version history (3 changes)0.1.0PHP ^5.5 || ^7.0

0.3.0PHP ^5.5 || ^7.0 || ^8.0

0.13.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0f82da10b7d506ac8ace5ac73477170d427bd89ad47becf19b1d2656daf4f182?d=identicon)[yatsenkolesh](/maintainers/yatsenkolesh)

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

---

Top Contributors

[![yatsenkolesh](https://avatars.githubusercontent.com/u/20239433?v=4)](https://github.com/yatsenkolesh "yatsenkolesh (75 commits)")[![ziming](https://avatars.githubusercontent.com/u/679513?v=4)](https://github.com/ziming "ziming (4 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![Omelya](https://avatars.githubusercontent.com/u/82599515?v=4)](https://github.com/Omelya "Omelya (1 commits)")

---

Tags

ab-testingab-testing-phpab-tests-laravelexperimentsexperiments-phpfeature-flagsfeature-togglefeature-toggle-phplaravellaravel-ab-testsphptracking-funnel

### Embed Badge

![Health badge](/badges/abrouter-laravel-abtest/health.svg)

```
[![Health](https://phpackages.com/badges/abrouter-laravel-abtest/health.svg)](https://phpackages.com/packages/abrouter-laravel-abtest)
```

###  Alternatives

[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)[crumbls/layup

A visual page builder plugin for Filament 5 — Divi-style grid layouts with extensible widgets.

592.7k1](/packages/crumbls-layup)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1320.9k4](/packages/team-nifty-gmbh-tall-datatables)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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