PHP Classes

How to Implement Laravel Feature Flags to Control Laravel Application Features Using the Package Feature Flag: Enable and disable features of Laravel application

Recommend this page to a friend!
  Info   View files View files (24)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-06-17 (2 days ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
feature-flag 1.0Custom (specified...7Libraries, Testing, PHP 7
Description 

Author

This package can enable and disable features of the Laravel application.

It provides a class to store the details of features of a Laravel application, such as the feature name, description, users that have the feature enabled, period of availability of the feature, etc...

The class can check if a given feature is currently enabled.

Features can be enabled and disabled with Artisan.

Picture of Mohamed Ahmed
  Performance   Level  
Name: Mohamed Ahmed <contact>
Classes: 1 package by
Country: Egypt Egypt
Innovation award
Innovation award
Nominee: 1x

Instructions

Usage

  //Feature Flagging can be simple done by creating the flag
  $featureFlag = new FeatureFlag([
          'name' => 'test',
          'description' => 'Test feature flag',
      ]);
  $featureFlag->save();

  //using the flag to scope your your code using if condition or any other way you like
  if ($featureFlag->isEnabled()) {
      // Implement the feature for the user
  }

  //or you can use the method Targted and checking the audience to match to specific audience
  if($featureFlag->isTargeted() && in_array($user->id, $featureFlag->getAudience())) {
      // Implement the feature for the user
  }

  //Feature Flagging can be also used to target users based on percentage
  $featureFlag = new FeatureFlag([
          'name' => 'test',
          'description' => 'Test feature flag',
          'percentage'=>50
      ]);
  $featureFlag->save();
  // you can use the method isEnabledForUser and checking the audience to match to specific audience i.e 50%
  if($featureFlag->isEnabledForUser($user)) {
      // Implement the feature for the user
  }
  //Feature Flagging can be also used to flag based on datetime 
  $featureFlag = new FeatureFlag([
          'name' => 'test flag',
          'finish_date' => '01/04/2023',
          'enabled' => true,
      ]);
  $featureFlag->save();
  // you can use the env either to throw an exception or send a notification when flag expires
  if($featureFlag->isEnabled()) {
      // Implement the feature for the user
  }
  //then simply call feature-flag:manage followed by the name of your flag to enable Or disable it 
  php artisan feature-flag:manage {flag : The name of the feature flag} 
  {--enable : Enable the feature flag} {--disable : Disable the feature flag}
  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imageconfig (1 file)
Files folder imagesrc (2 files, 6 directories)
Files folder imagetests (1 file, 1 directory)
Accessible without login Plain text file .env.testing Data Auxiliary data
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file CONTRIBUTING.md Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Image file logo.png Icon Icon image
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file main.yml Data Auxiliary data

  Files folder image Files  /  config  
File Role Description
  Accessible without login Plain text file config.php Aux. Configuration script

  Files folder image Files  /  src  
File Role Description
Files folder imageconfig (1 file)
Files folder imageConsole (1 file)
Files folder imageInterfaces (1 file)
Files folder imageMigrations (3 files)
Files folder imageModels (1 file)
Files folder imageNotifications (1 file)
  Plain text file FeatureFlagFacade.php Class Class source
  Plain text file FeatureFlagServiceProvider.php Class Class source

  Files folder image Files  /  src  /  config  
File Role Description
  Accessible without login Plain text file config.php Aux. Configuration script

  Files folder image Files  /  src  /  Console  
File Role Description
  Plain text file ManageFeatureFlagsCommand.php Class Class source

  Files folder image Files  /  src  /  Interfaces  
File Role Description
  Plain text file FeatureFlagInterface.php Class Class source

  Files folder image Files  /  src  /  Migrations  
File Role Description
  Plain text file 2018_08_08_00000_c...ure_flags_table.php Class Class source
  Plain text file 2018_08_09_00000_a...ure_flags_table.php Class Class source
  Plain text file 2018_08_10_00000_a...ure_flags_table.php Class Class source

  Files folder image Files  /  src  /  Models  
File Role Description
  Plain text file EloquentFeatureFlag.php Class Class source

  Files folder image Files  /  src  /  Notifications  
File Role Description
  Plain text file ExpiredFeatureFlagNotification.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageFeature (2 files)
  Plain text file TestCase.php Class Class source

  Files folder image Files  /  tests  /  Feature  
File Role Description
  Plain text file EloquentFeatureFlagTest.php Class Class source
  Plain text file FeatureFlagCommandTest.php Class Class source

 Version Control Unique User Downloads  
 100%
Total:0
This week:0