Skip to content

Instantly share code, notes, and snippets.

@Potherca Potherca/README.md
Last active Aug 16, 2019

Embed
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:

qandidate/toggle

https://github.com/qandidate-labs/qandidate-toggle

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

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

opensoft/rollout

https://github.com/opensoft/rollout

$toggle = new Rollout($features);

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

flagception/flagception

https://github.com/bestit/flagception-sdk

$manager = new FeatureManager($features);

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

joshuaestes/feature-toggle

https://github.com/JoshuaEstes/FeatureToggle

$manager = new FeatureContainer();
$manager->addFeature(FeatureBuilder::create('my_feature')->getFeature());

$manager->hasFeature('my_feature')->isEnabled();

zumba/swivel

https://github.com/zumba/swivel

$manager = new Manager(new Config($features, $bucket));
$manager->forFeature('my_feature');

Bonus!

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

https://github.com/etsy/feature

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

Commonalities

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.