PHP code example of evanperreau / laravel-feature-flags-lite

1. Go to this page and download the library: Download evanperreau/laravel-feature-flags-lite library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

evanperreau / laravel-feature-flags-lite example snippets




return [
    /*
     * Feature flags
     *
     * 'feature_name' => true,
     */
];



return [
    'new_ui' => true,
    'beta_feature' => false,
    'premium_feature' => true,
];

use Evanperreau\LaravelFeatureFlagsLite\Facades\Feature;

if (Feature::isEnabled('new_ui')) {
    // The 'new_ui' feature flag is enabled
}

if (feature('new_ui')) {
    // The 'new_ui' feature flag is enabled
}

use Evanperreau\LaravelFeatureFlagsLite\FeatureFlags;

class MyController
{
    public function index(FeatureFlags $featureFlags)
    {
        if ($featureFlags->isEnabled('new_ui')) {
            // The 'new_ui' feature flag is enabled
        }
    }
}

// Only accessible if 'premium_feature' is enabled
Route::get('/premium-content', 'PremiumController@index')
    ->middleware('feature:premium_feature');

// Returns 403 Forbidden if 'beta_feature' is disabled
Route::get('/beta-feature', 'BetaController@index')
    ->middleware('feature:beta_feature,403');

// All routes in this group admin_panel')->group(function () {
    Route::get('/admin/dashboard', 'AdminController@dashboard');
    Route::get('/admin/users', 'AdminController@users');
    Route::get('/admin/settings', 'AdminController@settings');
});



return [
    'new_ui' => env('FEATURE_NEW_UI', false),
    'beta_feature' => env('FEATURE_BETA_FEATURE', false),
];
bash
php artisan vendor:publish --provider="Evanperreau\LaravelFeatureFlagsLite\FeatureFlagsServiceProvider" --tag="config"

FEATURE_NEW_UI=true
FEATURE_BETA_FEATURE=false