PHPackages                             ssola/enabler - 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. [Security](/categories/security)
4. /
5. ssola/enabler

ActiveLibrary[Security](/categories/security)

ssola/enabler
=============

Enable a functionality to specific IP, specific group / users or by percentage of visitors.

1.0.0(11y ago)22151MITPHP

Since Nov 27Pushed 11y ago2 watchersCompare

[ Source](https://github.com/ssola/enabler)[ Packagist](https://packagist.org/packages/ssola/enabler)[ RSS](/packages/ssola-enabler/feed)WikiDiscussions master Synced 1mo ago

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

enabler [![Build Status](https://camo.githubusercontent.com/736cd67472919b1faf2577ad8098984268123124be5d983ee6dc50fe1be67a7d/68747470733a2f2f7472617669732d63692e6f72672f73736f6c612f656e61626c65722e737667)](https://travis-ci.org/ssola/enabler) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/bc123ca0769c62200131550fc19f0d5a7c61c3f32a6af1325d305027f3ae5eac/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73736f6c612f656e61626c65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ssola/enabler/?branch=master)
=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#enabler--)

Enabler is a simple feature flag package. With this package you can display/hide your awesome new features to customers in order to deploy your new stuff smoothly and to have everything under control.

I would like to know what do you think about this package and if you have an idea about how to improve this package plase create a new issue.

### Requirements

[](#requirements)

To use this package you only need to have:

- PHP &gt;= 5.4
- Redis (it's our default persistence tool)
- Composer

If you need a different persistence tool like Memcache or MySQL you can simply write your own Storable adapter.

### Installation

[](#installation)

composer require ssola/enabler

composer update

### How it works?

[](#how-it-works)

With Enabler is really simple to show/hide features to your users. Let me show how it works with this little example:

*Requirement:*We need to deploy our new killer feature gradually. We expect a lot of new people using it and we need to be completely sure that it works properly. At this stage we only want to enable this feature to a really small set of customers: exactly 1% of them.

First of all we have to create our new Feature and include which filters should be used.

```
$feature = new Enabler\Feature(
  'secret-feature',
  true,
  [
    'Enabler\Filter\Distributed' => [1]
  ]
);

$enabler = new Enabler\Enabler($storage);
$enabler->storage()->create($feature);

// At this point feature has been created and will use the Distributed filter to display it only to 1% of our visitors
// after this we can create the condition:

if ($enabler->enabled('secret-feature')) {
  // Here your feature for only 1% of your visitors.
}
```

Finally you determined to test your new Feature in a new scenario. In this respect we only want to reveal it to logged in customers.For that logic we have implemented the Identifier filter. You only have to instantiate an Identity object passing the required user data. In this case we must to pass the user id and group to which it belongs.

```
$identity = new Enabler\Identity(MyUserClass::getUserId(), MyUserClass::getGroup());

$feature = new Enabler\Feature(
  'secret-feature',
  true,
  [
    'Enabler\Filter\Identifier' => ['groups' => ['early-adopters', 'test-users']]
  ]
);

$enabler = new Enabler\Enabler($storage, $identity);
$enabler->storage()->create($feature);

if ($enabler->enabled('secret-feature')) {
  // Here your feature for users that belongs to early-adopters or test-users group
}
```

But now imagine that we need to display only to a bigger amount (10%) of our test-users group in a particular date range. We can do it easily adding more than one filter to the feature filter chain, like this:

```
$identity = new Enabler\Identity(MyUserClass::getUserId(), MyUserClass::getGroup());

$feature = new Enabler\Feature(
  'secret-feature',
  true,
  [
    'Enabler\Filter\Distributed' => [10],
    'Enabler\Filter\Identifier' => ['groups' => ['test-users']],
    'Enabler\Filter\Date' => ['from' => new DateTime('2014-10-30'), 'to' => new DateTime('2015-10-30')]
  ]
);

$enabler = new Enabler\Enabler($storage, $identity);
$enabler->storage()->create($feature);

if ($enabler->enabled('secret-feature')) {
  // Here your feature for users that belongs to early-adopters or test-users group
}
```

### Extend me

[](#extend-me)

#### Storage

[](#storage)

We need a storage adapter to be able to store your Feature configuration in some place. Our default storage tool is Redis, but if feel free to write your own adapters.

It's as simples as this:

```
class MyAwesomeStorageAdapter implements Enabler\Storage\Storable
{
  public function create (Feature $feature) {
    // do your magic here!
  }

  public function delete ($name) {
    // delete a specific Feature
  }

  public function get ($name) {
    return $myFeature;
  }
}
```

\#### Filters

At the moment we support four different filters Random Weighted Distribution, IP, Date / Date Range and Identity. But we thought people will have great ideas and it's really simple to create your own filters.

```
class FilterByWeather implements Enabler\Filter\Filterable
{
  public function filter ($value, Feature $feature, Identity $identity) {
    // our value is Sunny
    $currentWeather = Weather::getFromIp(IP::getIp());

    if($currentWeather == $value) {
      return true;
    }

    return false;
  }
}
```

### Features

[](#features)

You can choose among different filters or create your owns in order to displar/hide your features:

- By IP: Display your feature only to certain IP or IP range (TBD)
- By Random weight distribution: You can display your feature for example only to 10% or your visitors
- By Identity: Use our Identity class or create your own in order to have access to User Id and/or Group.
- By date or date range: Display your feature depending on specific date or set a range to display it only for a precise range of dates.

[![Bitdeli Badge](https://camo.githubusercontent.com/4ebc6736ef591182b8376bb7cad68664867c7baccb5427107e94e4d1e98209c8/68747470733a2f2f64327765637a68766c38323376302e636c6f756466726f6e742e6e65742f73736f6c612f656e61626c65722f7472656e642e706e67)](https://bitdeli.com/free "Bitdeli Badge")

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

4188d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0489f67bef65773d8ec49277f1f0a82efffaab33adf47b0b9ba753cc72633d44?d=identicon)[ssola](/maintainers/ssola)

---

Top Contributors

[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")

### Embed Badge

![Health badge](/badges/ssola-enabler/health.svg)

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

###  Alternatives

[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[maba/gentle-force

Library for limiting both brute-force attempts and ordinary requests, using leaky/token bucket algorithm, based on Redis

45591.0k2](/packages/maba-gentle-force)[jeroenvisser101/leakybucket

An implementation of the Leaky Bucket algorithm.

44116.6k](/packages/jeroenvisser101-leakybucket)[potelo/laravel-block-bots

Block bots and high traffic offenders using Redis

5514.0k](/packages/potelo-laravel-block-bots)[wafris/laravel-wafris

Wafris for Laravel

161.1k](/packages/wafris-laravel-wafris)

PHPackages © 2026

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