2017 © Pedro Peláez

library laravel-bento

Laravel module to launch features at people.



Laravel module to launch features at people.

  • Friday, October 20, 2017
  • by xel1045
  • Repository
  • 1 Watchers
  • 4 Stars
  • 67 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 6 Open issues
  • 2 Versions
  • 16 % Grown


Laravel Bento

Latest Stable Version Software License Build Status StyleCI Total Downloads, (*1)

Bento helps you organize feature launches by custom user segments. Create and organize rules to make features available to certain users., (*2)

Define your features, define your segmentation strategies and let Bento launch each feature to the right people. Bento can also help you run A/B testing on your applications., (*3)

The core concepts of this library are inspired by Airbnb's Trebuchet project for Ruby., (*4)


Require this package with composer:, (*5)

composer require eXolnet/laravel-bento

After installing Bento, publish its example service provider to hold your feature definitions:, (*6)

php artisan vendor:publish --tag=bento-provider

Then, add it to the providers array in config/app.php:, (*7)



Create Features

Define features and their launch segmentation strategies. You can define one strategy with the aim method:, (*8)

Bento::aim('feature', 'visitor-percent', 10);

Or you can combine multiple strategies:, (*9)

Bento::feature('feature')->aim('visitor-percent', 10)->aim('hostname', 'example.com');

Launch Your Features

You can check if a feature is launched for a visitor with the launch method:, (*10)

if (Bento::launch('feature')) {

Or check that a feature is awaiting launch:, (*11)

if (Bento::await('feature')) {


In Blade templates, handy macros are also available:, (*12)

    Feature is launched!
    Coming soon!
    Coming soon!
    Feature is launched!


Since some strategy requires the request context to be evaluated, it's recommended to use the Feature middleware to limit a route:, (*13)

  1. Add the Feature middleware in the $routeMiddleware of your application's HTTP Kernel:
    protected $routeMiddleware = [
        // ...
        'launch' => \Exolnet\Bento\Middleware\Launch::class,
        // ...
  1. Then, you could use it to restrict your routes:
Route::middleware('launch:feature')->group(function () {

Basic Segmentation Strategies

The following segmentation strategies are available to help quickly target your users:, (*14)

  • Date
  • Environment
  • Everyone
  • Guest
  • Hostname
  • Nobody
  • User (authenticated or specific user IDs)
  • User Percent (a fraction of all connected visitors)
  • Visitor Percent (a fraction of all your visitors)

Logic Segmentation Strategies

Additional logic segmentation strategies are available to help target your users with more complex rules., (*15)

Logic Not

Bento::aim('feature', 'logic-not', 'everybody');

Logic And

Bento::aim('feature', 'logic-and', function($feature) {
        ->aim('environment', 'production')
        ->aim('visitor-percent', 20);

Logic Or

Bento::aim('feature', 'logic-or', function($feature) {
        ->aim('environment', 'staging')
        ->aim('user', [1, 2]);

Custom Segmentation Strategies

You can create your own custom strategies., (*16)

You can also inject dependencies the same way Laravel Controllers' method injection works. A common use-case for method injection is injecting the Illuminate\Contracts\Auth\Guard instance into your strategy to target users by property:, (*17)

use Illuminate\Contracts\Auth\Guard;

Bento::defineStrategy('role', function(Guard $guard, $role) {
    return $guard->user() && $guard->user()->role === $role;

Then, you can use your custom strategy like the default one:, (*18)

Bento::feature('feature')->aim('role', 'admin');


To run the phpUnit tests, please use:, (*19)

bash $ composer test, (*20)


Please see CONTRIBUTING and CODE OF CONDUCT for details., (*21)


If you discover any security related issues, please email security@exolnet.com instead of using the issue tracker., (*22)



This code is licensed under the MIT license. Please see the license file for more information., (*23)

The Versions

20/10 2017



Laravel module to launch features at people.

  Sources   Download


The Requires


The Development Requires

laravel ab feature target aim

01/08 2017


Laravel module to launch features at people.

  Sources   Download


The Requires


The Development Requires

laravel ab feature target aim