Skip to content

Instantly share code, notes, and snippets.

@Potherca Potherca/
Last active Aug 16, 2019

What would you like to do?
Feature Toggles in PHP

If you look on Packagist, the most popular packages for Feature toggles are:

  1. qandidate/toggle "Feature toggling for your PHP application." (⬇️ 496.754 / ⭐ 362)
  2. opensoft/rollout "Feature switches or flags for PHP" (⬇️ 354.269 / ⭐ 215)
  3. flagception/flagception "Feature toggle on steroids." (⬇️ 139 265 / ⭐ 24)
  4. joshuaestes/feature-toggle "Provides feature toggle functionality" (⬇️ 61.736 / ⭐ 32)
  5. zumba/swivel "Strategy driven feature toggles" (⬇️ 49.954 / ⭐ 211)

Downloads Stars

Class API

These packages have the following class API:


$manager = new ToggleManager($features);
$manager->add(new Toggle('my_feature', $condition));

$manager->active('my_feature', $context)


$toggle = new Rollout($features);

$toggle->isActive('my_feature', $context);


$manager = new FeatureManager($features);

$manager->isActive('my_feature', (new Context())->add('my_feature', $context));


$manager = new FeatureContainer();



$manager = new Manager(new Config($features, $bucket));


Because it was one of the first, I'll also add etsy/feature

Feature::isEnabledFor('my_feature', $context)
Feature::variantFor('my_feature', $context)


The most common patterns seem to be to have either a FeatureToggle or Collection/Manager of FeatureToggles. Either of which can be asked for a specific feature to be active, optionally given a specific context. (Variants and Buckets are not in scope of this comparison yet).

The following are all more or less synonimous:

  • active
  • isActive
  • isEnabled

Comparing these (either by stars or downloads) "active" seem to be the winner over "feature.

Downloads Stars

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.