abrouter/symfony-abtest

ABRouter Symfony AB test is a simple package for the base library to run ab-tests via ABRouter with Symfony. Prepare and run your ab-test in 10 minutes. Easy to manage and run. Can be also used as a feature flag or feature toggle. Available for free.

0.1.0 2022-06-04 14:01 UTC

This package is auto-updated.

Last update: 2024-11-17 15:57:46 UTC


README

ABRouter AB Test 👷‍♀️ is a simple package for base library to run A/B tests via ABRouter with Symfony. You can find base PHP library in https://github.com/abrouter/abrouter-php-client

You're welcome to visit the docs.

What is the ABRouter service ?

ABRouter is the service to manage experiments(A/B split tests). The service provides easy to manage dashboard to keep experiments under control. There you can create experiments, branches and set 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.

Can be also used as a feature flag or feature toggle. Available for free.

Prepare your first A/B test

Besides of the installing this package you need to have an account on ABRouter. Your token and experiment id will be also there.

📦 Install

Via composer

$ composer require abrouter/symfony-abtest

Register the bundle

Register bundle

// config/bundles.php
return [
    // [...]
    Abrouter\SymfonyClient\AbrouterClientBundle::class => ['all' => true],
];

Configure ABRouter client:

Put your ABRouter token in /config/packages/abrouter_client.yaml. You can find this token in ABRouter dashboard.

abrouter_client:
  token:                'YOUR_TOKEN'
  host:                 'https://abrouter.com'

🚀 Usage

use Abrouter\Client\Client;

class ExampleController
{
    public function __invoke(Client $client)
    {
        $buttonColorExperimentId = 'D1D06000-0000-0000-00005030';
        return new Response(json_encode([
            'button_color' => $client
                ->experiments()
                ->run('USER_ID', $buttonColorExperimentId),
        ]));
    }
}

You can create an experiment and get your token and id of experiment on ABRouter or just read the docs.

Example

You can get an dockerized usage example by the following link: (https://github.com/abrouter/symfony-abtest-example)

🔧 Contributing

Please feel free to fork and sending Pull Requests. This project follows Semantic Versioning 2 and PSR-2.

📄 License

GPL3. Please see License File for more information.