2017 © Pedro Peláez
 

library feature-flags

Feature flags

image

vestd/feature-flags

Feature flags

  • Monday, February 1, 2016
  • by ArthurGuy
  • Repository
  • 4 Watchers
  • 0 Stars
  • 4,151 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Feature flags

This is a basic Laravel 5 package for implementing feature flags., (*1)

Installation

First, pull in the package through Composer., (*2)

composer require vestd/feature-flags

And then, if using Laravel 5, include the service provider within app/config/app.php., (*3)

'providers' => [
    Vestd\FeatureFlags\FeatureFlagServiceProvider::class
];

And finally publish the config file, this will be where you put the feature flag configuration, (*4)

php artisan vendor:publish --provider="Vestd\FeatureFlags\FeatureFlagServiceProvider"

Usage in Laravel

Within your codebase use Laravel's dependency injection to load in the FeatureFlags container. You can then call the get method to retrieve a previously configured feature flag. If the flag doesn't exist an exception will be thrown., (*5)

public function index(FeatureCollection $featureCollection)
{
    $feature = $featureCollection->get('new_home_page');

    if ($feature->isEnabled()) {
        view('new_homepage');
    } else {
        view('homepage');
    }
}

Configuration

In its simplest form the configuration file will allow to to specify a key and a true or false flag, (*6)

  'feature_a' => true,
  'feature_b' => false,

The alternative method is an associative array for the keys, using this method you can specify which users or groups would have access to the feature, (*7)


'feature_c' => [ 'users' => [123, 456], 'groups' => ['admin', 'beta'], ]

If you use the more complex features you can check the state by using the following isEnabled checks, (*8)

public function index(FeatureFlags $featureFlags)
{
    $feature = $featureFlags->get('new_home_page');

    if ($feature->isEnabledForUser(456) || $feature->isEnabledForGroup('admin')) {
        view('new_homepage');
    } else {
        view('homepage');
    }
}

Coming soon

The ability to configure the flags through a method other than a fixed config file, i.e. a database, (*9)

Contributing

Contributions are accepted but this package is being developed primarily for use within the Vestd app so if your use case differs too much from what we need it may not be accepted., (*10)

The Versions

01/02 2016

dev-master

9999999-dev

Feature flags

  Sources   Download

MIT

The Requires

 

The Development Requires

01/02 2016

1.0.0

1.0.0.0

Feature flags

  Sources   Download

MIT

The Requires

 

The Development Requires

01/02 2016

0.9.1

0.9.1.0

Feature flags

  Sources   Download

MIT

The Requires

 

The Development Requires

01/02 2016

0.9

0.9.0.0

Feature flags

  Sources   Download

MIT

The Requires

 

The Development Requires