PHPackages                             dose/laravelfeature - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. dose/laravelfeature

ActiveLibrary[Testing &amp; Quality](/categories/testing)

dose/laravelfeature
===================

Rampup and AB testing library inspired for Laravel.

1.0.0(10y ago)2964MITPHPPHP &gt;=5.4.0

Since Feb 3Pushed 9y ago6 watchersCompare

[ Source](https://github.com/MattStypa/LaravelFeature)[ Packagist](https://packagist.org/packages/dose/laravelfeature)[ Docs](https://github.com/spartzinc/laravelfeature/)[ RSS](/packages/dose-laravelfeature/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

LaravelFeature
==============

[](#laravelfeature)

[![Build Status](https://camo.githubusercontent.com/359ddf65102c73ff5afa99828d646cbdae3a23eedbc6b3bbf109a86aa73707c5/68747470733a2f2f7472617669732d63692e6f72672f4d61747453747970612f4c61726176656c466561747572652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/SpartzInc/LaravelFeature)[![Latest Stable Version](https://camo.githubusercontent.com/d581a01df216ec8ef8ac3bb94460a406fccabd468287aa14b5e33a283bbf1d6d/68747470733a2f2f706f7365722e707567782e6f72672f646f73652f6c61726176656c666561747572652f762f737461626c65)](https://packagist.org/packages/dose/laravelfeature)[![Total Downloads](https://camo.githubusercontent.com/402f8afed3b1943c345afc2a42f694edf32a0c8d5c3efcdb8bf37bc2f6a029b4/68747470733a2f2f706f7365722e707567782e6f72672f646f73652f6c61726176656c666561747572652f646f776e6c6f616473)](https://packagist.org/packages/dose/laravelfeature)[![Latest Unstable Version](https://camo.githubusercontent.com/028200c8a0a4949522db8c2ad958f8d112678aaf102c44498911e0792bf58611/68747470733a2f2f706f7365722e707567782e6f72672f646f73652f6c61726176656c666561747572652f762f756e737461626c65)](https://packagist.org/packages/dose/laravelfeature)[![License](https://camo.githubusercontent.com/efb2222f4403bdd914fdd44c6c8e67d376cf55b250a70c1defeb9b4368f23322/68747470733a2f2f706f7365722e707567782e6f72672f646f73652f6c61726176656c666561747572652f6c6963656e7365)](https://packagist.org/packages/dose/laravelfeature)

Rampup and AB testing library inspired by Etsy\\Feature for Laravel.

How to use
----------

[](#how-to-use)

After you have added this package to your composer file you will need to register it's Service Provider.

```
'Dose\LaravelFeature\LaravelFeatureServiceProvider'

```

You also want to publish configuration so you can define your features.

```
php artisan config:publish dose/laravelfeature // Laravel 4
php artisan vendor:publish --provider="Dose\LaravelFeature\LaravelFeatureServiceProvider" // Laravel 5

```

To gain access to the API you need to resolve an instance out of the Service Container.

```
$feature = app()->make('Dose\LaravelFeature\LaravelFeatureInterface');

```

Of course, dependency injection can also be used.

### Get Variant

[](#get-variant)

```
$feature->getVariant($name);

```

This will return a selected variant. It may also return NULL if the feature does not exist or if none of the variants were selected (features with incomplete coverage).

### Set Context

[](#set-context)

```
$feature->setContext($context);

```

This is not something commonly used but it lets you change the context in which a variant is selected. By default, user's session id is used. This means that the variant will be the same for the span of the session.

Sometimes you might want to rotate variants based on different criteria. For example, if you want all posts by a certain author to have a set of features consistent for all users. You can do that by setting the context.

```
$feature->setContext('post_author:' . $postAuthor);

```

AB Testing
----------

[](#ab-testing)

It is a common use case to run multiple AB tests with multiple variants at the same time. In order to get valuable test results, only one test can be active at once. In order to achieve this, you need to define a wrapper feature. The variants will represent each test.

```
'tests' => [
    'test_a',
    'test_b',
    'test_c',
],
'test_a' => [
   'variant_a',
   'variant_b',
],
'test_b' => [
   'variant_a',
   'variant_b',
],
'test_c' => [
   'variant_a',
   'variant_b',
],

```

This allows us to check if a particular test is active and then retrieve it's variant.

```
if ($feature->getVariant('tests') == 'test_a') {
    $variant = $feature->getVariant('test_a');
}

```

Config
------

[](#config)

There are two configuration files that you can use to control the behavior.

### config.php

[](#configphp)

In this file, you can specify if you want users to be able to override the variant selection with a specific URL parameter.

```
'allow_override' => false,

```

This is disabled by default. You may control who can use the URL override by defining your own logic.

```
'allow_override' => Gate::allows('feature_url_override'),

```

### features.php

[](#featuresphp)

All your features are defined here.

There is a ton of flexibility in defining features. We will start with the most verbose and then work down.

Each feature can have any number of variants with each variant defining it's own odds.

```
'feature' => [
    'variant_a' => 25,
    'variant_b' => 25,
    'variant_c' => 50,
],

```

In the above example, each variant has the specified chance of being selected. Variants with odds below 0 are normalized to 0. The variants are processed top to bottom. If the sum of odds exceeds 100 the feature is saturated and any variants above that threshold have no chance of being selected.

```
'feature' => [
    'variant_a' => 100,
    'variant_b' => 25,
    'variant_c' => 50,
],

```

The above feature will always return variant\_a.

You can omit the odds and just specify the variants. In this case, the variants are evenly spread out.

```
'feature' => [
    'variant_a',
    'variant_b',
],

```

In this case, both variants have 50% chance of being selected.

These approaches can be mixed. It is important to note that variants with specified odds will be processed first and then any remaining odds are distributed among the auto-scaled variants.

```
'feature' => [
    'variant_a' => 50,
    'variant_b',
    'variant_c',
],

```

The first variant has 50% chance of coming up while the other two have 25% chance each.

To specify a simple ON/OFF feature we just include a single variant.

```
'feature' => [
    'enabled' => 100,
],

```

This feature is always on. We can adjust the odds to turn it off completely or achieve a ramp-up functionality.

It is also possible to shorten the above example by just defining the odds for the feature itself.

```
'feature' => 50,

```

This feature will be on for 50% of the users.

URL override
------------

[](#url-override)

If the URL override is enabled you can force a particular variant by specifying it in the URL

```
?features=example_feature:variant_1

```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3794d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d462e83008c683703a82b06770e625b92114a119a09d668b690ceb604fd9b54?d=identicon)[MattStypa](/maintainers/MattStypa)

---

Top Contributors

[![MattStypa](https://avatars.githubusercontent.com/u/5871133?v=4)](https://github.com/MattStypa "MattStypa (8 commits)")

---

Tags

laravelfeatureab-testingrampup

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dose-laravelfeature/health.svg)

```
[![Health](https://phpackages.com/badges/dose-laravelfeature/health.svg)](https://phpackages.com/packages/dose-laravelfeature)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.6k](/packages/larastan-larastan)[illuminate/routing

The Illuminate Routing package.

1239.0M2.8k](/packages/illuminate-routing)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)[calebdw/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

15104.9k4](/packages/calebdw-larastan)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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