PHP code example of matthiaswilbrink / laravel-feature-toggles

1. Go to this page and download the library: Download matthiaswilbrink/laravel-feature-toggles 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/ */

    

matthiaswilbrink / laravel-feature-toggles example snippets


[...]
@feature('name_of_my_feature_as_string')
    This will show when the feature is enabled
@endfeature
[...]

[...]
@feature('name_of_my_feature_as_string')
    This will show when the feature is enabled.
@else
    This will show when the feature is disabled.
@endfeature
[...]

if (feature('name_of_my_feature_as_string')){
    //do something
}

// Check if a feature is enabled
if (Feature::isEnabled('name_of_my_feature_as_string')){
    //do something
}

// A shorter alias
if (Feature::isOn('name_of_my_feature_as_string')){
    //do something
}

public function someMethod(FeatureManager $featureManager)
{
    if ($featureManager->isEnabled('name_of_my_feature_as_string')){
        //do something
    }
}

public function turnTheSnowFlakesOn(FeatureManager $featureManager)
{
    $featureManager->enable('homepage_snowflakes_animation');
}
shell
php artisan vendor:publish --provider="MatthiasWilbrink\FeatureToggle\Providers\FeatureToggleServiceProvider"
shell
php artisan migrate