How to bring the feature flags to your Laravel project?

ABRouter is a platform that solves products problems and helps to improve conversions and user experience. We focused on the developer experience, finite user experience, and of course, on your business. In this post, we'll talk about the implementation of feature flags in Laravel.


Common feature flags definition

Feature flags are also known as feature toggles. The feature flags are configurations that allow you to enable or disable some part of your code in your application. So, you can control the specific feature in your app in any environment.
Usually, enabling or disabling is working fast, and changes will take effect immediately, and that's critical nowadays. Technically feature flag looks like a true or false value received by the HTTPS(internet) call or via another transport with the remote server.
Start for free
Use cases

Feature flags use-cases

I hope you're interested in using feature flags. There are the following
reasons to bring it to your Laravel application:
Faster delivery to production.

Sometimes it's the only way to deliver the feature in production. If you're waiting for someone, front end, for example, you have to wait.

While your feature branch is waiting for the deployment, the code could be broken by someone, or someone from your team will change it and throw you into the work with VCS conflicts. Based on my experience, it's better to deploy when your code is fresh.

Only one thing which you and your team have to test carefully when you release the feature flag is the correct isolation of the new code. With the right level of code isolation, you can sleep well and disable your feature flag anytime and then fix it and enable it again.

Change of the highly-important part of the application that always should be controlled.

When you change part of your application the mistake can be too expensive, so the right decision is to care about it early and make the change under the feature flag. Feature flags do not imply any measurement of payments or conversions for the changed code, so it will work faster and perfectly fits this goal.

And the last, but not least is code which shell works time-to-time.

For example, it can be a captcha, rate liming, or email confirmation on the sign-up step. You can enable something from it when your Laravel application is experiencing some kind of additional load.


Plan your first Laravel feature flag

Task definition:
Our task for today is to wrap the two HTML buttons to the feature flag, one enabled and one - disabled.

So, we can turn on or turn off one of the buttons or both anytime. Just the usual if-statements with some additional preparation to start working on the ABRouter platform and basic wiring the client in your Laravel project codebase.

From words to work

Follow the steps, it's easy:
Step 1: Sign-up by the link
Step 2: Create your feature flags.
Step 3: Grab the data

After creating the A/B test you can to get the important data to run it.

Step 4: Install

Install the library to your codebase on PHP:

This library based on main ABRouter client:

This library includes ab-tests and feature flags managing on ABRouter.

  • Install the package:
    composer require abrouter/laravel-abtest

    This package provide auto discovery for service provider. If Symfony package auto-discovery is disabled, add service providers manually in your /app/app.php of your repository.

    There are service providers you must add:


  • Publish client configuration:
    php artisan vendor:publish --tag=abrouter
  • Configure the client:

    There you have to put your ABRouter token from your dashboard which is described in the third point.

Step 5: Code

Now we are ready to code. Also, you can check an example of fully completed code on GitHub:

Step 6: There is our result

One of the button is displayed and one is hidden under the if statement with turned of feature flag.

On this page
Step 1: Sign-up by the link
Step 2: Create your feature flags.
Step 3: Grab the data
Step 4: Install
Step 5: Code
Step 6: There is our result

Getting started is easy

Deploy with feature flags is not stress anymore
Create your first feature flag


I have shown you how to implement the feature flag with Laravel framework via ABRouter. Looks like it's quite simple. Please, remember, that huge or uncertain changes, that couldn't be tested with a/b test should be implemented via feature flag to prevent unpredictable situations and save your business.

If you have any questions, feel free to ask me at