How to implement A/B | split tests with Symfony?

The ABRouter is an open-source, developer-oriented tool for implementing managed A/B tests with high-level Symfony support.
The service providing a clear web interface to manage experiments, powerful API to run and track results of the tests in your Symfony application.
Installing via composer package for Symfony.
Please, checkout out package GitHub Repository.
Takes minutes to start your first A/B test. Additionally, we have the packages for vanilla PHP and Laravel:

PHP guide
Laravel guide

Start for free


Why do we need A/B tests?

Long story short - to improve conversions. The main advantage of AB-testing is making the right decisions.

Real world example: you have a two implementations of free trials on your website. In the first case, you require a card number to sign up, and for the second your user can proceed to the platform without the card. What is the best choice in that case?

AB test with two branches can show you the right answer. Your decision will be based on the number of completed sign-ups and the final number of the paid users in these branches.

Start for free

Our first task with A/B test

Task definition
Our task is testing the most convertible color of form button. For example, your current color of sign up button is blue, but you want to check, what if the green button will be more convertible?
to test most convertible color of form button
red - 33%, green - 33%, blue - 33%.
assign the color of the button: which the user got into.

Creating first A/B test on ABR side

So, there are the step to be done:
Step 1: Sign-up by the link
Step 2: Create your experiment
Pay attention to the Experiment ID. You will use it as the identifier of experiment to run it.
Step 3: Grab the data
After creating the A/B test you can to get the important data to run it.
Experiment id:


Application side | Start coding

Step 1: Install
Install the library to your codebase on PHP:
This library based on main ABRouter client:
Install the package:
composer require abrouter/symfony-abtest
Register the bundle:
// config/bundles.php
return [
// [...]
Abrouter\SymfonyClient\AbrouterClientBundle::class => ['all' => true],
Configure the client:
Put your ABRouter token in /config/packages/abrouter_client.yaml
  token:                ''
  host:                 ''

This file on GitHub
Step 2: Code
Now we are ready to code. Also, you can check an example of fully completed code on GitHub:
Step 3: There is our result
Color of the button will be automatically changed on each request for every page reload. Because we have used uniqid(). ABRouter system will memorize the relation between user identifier and branch he got, so if we will repeat the request with the same user identifier we will get the same branch as on previous run.

You're don't need to implement it on your own

Because we already did it in a perfect way in ABRouter open-source platform for A/B testing and feature flags!

Branch memorization & User identifiers association
ABRouter system will keep the user in the same branch after he got it the first time. It’s important to keep the user in the same branch all the time. With user identifiers association we will accept the relations between permanent user id and guest user id and keep the user in the same branch. Make an association through sending both identifiers in single statistic event.
Viewing statistics by branch
We will match the branch with the users events and show you detailed statistics which will help you to decide the better performed branch to make it base line.
Useful UI
We have implemented first-class UI to manage your A/B tests, feature flags and viewing statistics. It will help you to make the important decisions on your product and increase the your product growth.

Start tracking your A/B test

You can learn more about tracking user events in the docs. Tracking user events is important for making decisions on your experiments. After implementing the sending of events you can see the statistics by users which got into the experiment. ABRouter supports viewing the stats by the experiment and over all statistics.

Getting started is easy

Find key revenue drivers with ABRouter
Create your first A/B test


I have shown you how to implement an A/B test with Symfony framework via ABRouter. Looks like it's quite simple.
Please, remember, that every change that you are making to the app should be through an A/B test. It's a key to build a successful product.

If you have any questions, feel free to ask me at or via green "Ask Us" button here.

Alex Yatsenko Senior Developer at ABRouter