An Unleash client for Laravel.
composer require mikefrancis/laravel-unleash
Export package config:
php artisan vendor:publish --provider="MikeFrancis\LaravelUnleash\ServiceProvider"
Documentation for configuration can be found in config/unleash.php.
use \MikeFrancis\LaravelUnleash\Unleash;
$unleash = app(Unleash::class);
if ($unleash->isFeatureEnabled('myAwesomeFeature')) {
// Congratulations, you can see this awesome feature!
}
if ($unleash->isFeatureDisabled('myAwesomeFeature')) {
// Check back later for more features!
}
$feature = $unleash->getFeature('myAwesomeFeature');
$allFeatures = $unleash->getFeatures();
You can use the Unleash
facade:
use Unleash;
if (Unleash::isFeatureEnabled('myAwesomeFeature')) {
// Congratulations, you can see this awesome feature!
}
if (Unleash::isFeatureDisabled('myAwesomeFeature')) {
// Check back later for more features!
}
$feature = Unleash::getFeature('myAwesomeFeature');
$allFeatures = Unleash::getFeatures();
or use the generically named Feature
facade:
use Feature;
if (Feature::enabled('myAwesomeFeature')) {
// Congratulations, you can see this awesome feature!
}
if (Feature::disabled('myAwesomeFeature')) {
// Check back later for more features!
}
$feature = Feature::get('myAwesomeFeature');
$allFeatures = Feature::all();
If your strategy relies on dynamic data at runtime, you can pass additional arguments to the feature check functions:
use \MikeFrancis\LaravelUnleash\Unleash;
use Config;
$unleash = app(Unleash::class);
$allowList = config('app.allow_list');
if ($unleash->isFeatureEnabled('myAwesomeFeature', $allowList)) {
// Congratulations, you can see this awesome feature!
}
if ($unleash->isFeatureDisabled('myAwesomeFeature', $allowList)) {
// Check back later for more features!
}
Blade directive for checking if a feature is enabled:
@featureEnabled('myAwesomeFeature')
Congratulations, you can see this awesome feature!
@endfeatureEnabled
Or if a feature is disabled:
@featureDisabled('myAwesomeFeature')
Check back later for more features!
@endfeatureDisabled
You cannot currently use dynamic strategy arguments with Blade template directives.