PHP code example of codinglabsau / laravel-feature-flags
1. Go to this page and download the library: Download codinglabsau/laravel-feature-flags 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/ */
codinglabsau / laravel-feature-flags example snippets
use Codinglabs\FeatureFlags\Models\Feature;
use Codinglabs\FeatureFlags\Enums\FeatureState;
Feature::create([
'name' => 'search-v2',
'state' => FeatureState::on()
]);
@feature('search-v2')
// new search goes here
@else
// legacy search here
@endfeature
use Codinglabs\FeatureFlags\Facades\FeatureFlag;
if (FeatureFlag::isOn('search-v2')) {
// new feature code
} else {
// old code
}
@unlessfeature('search-v2')
// no new features for you
@endfeature
use Codinglabs\FeatureFlags\Facades\FeatureFlag;
if (FeatureFlag::isOff('search-v2')) {
// no new features for you
}
use Codinglabs\FeatureFlags\Facades\FeatureFlag;
// value from Codinglabs\FeatureFlags\Enums\FeatureState
$featureState = FeatureFlag::getState('search-v2');
use Codinglabs\FeatureFlags\Facades\FeatureFlag;
FeatureFlag::turnOn('search-v2');
FeatureFlag::turnOff('search-v2');
FeatureFlag::makeDynamic('search-v2');