infi-nl / laravel-feature-toggle
Laravel 5 package wrapping joshuaestes/feature-toggle
Installs: 3 486
Dependents: 0
Suggesters: 0
Security: 0
Stars: 15
Watchers: 8
Forks: 2
Open Issues: 1
Requires
- php: >=5.3.0
- illuminate/support: 4.1.*
- joshuaestes/feature-toggle: 0.1.*
Requires (Dev)
- phpunit/phpunit: 3.7.*
- squizlabs/php_codesniffer: 1.*
This package is not auto-updated.
Last update: 2021-04-02 21:40:06 UTC
README
Laravel wrapper for JoshuaEstes/FeatureToggle, a library which allows you to easily add and modify various features to your code while in development.
Installation
Add the following line to the require
section of composer.json
:
{ "require": { "infi-nl/laravel-feature-toggle": "dev-master" } }
Setup
- Add
'InfiNl\LaravelFeatureToggle\LaravelFeatureToggleServiceProvider',
to the service provider list inapp/config/app.php
. - Add
'FeatureContainer' => 'InfiNl\LaravelFeatureToggle\Facades\FeatureContainerFacade',
to the list of aliases inapp/config/app.php
.
Configuration
Create the file <app_root>/config/packages/infi-nl/laravel-feature-toggle/feature.php and modify it to suit your needs.
The configuration file must be formatted like this:
<?php return array( "featureName1" => array( "enabled" => true ), ... "featureNameN" => array( "enabled" => false ) );
Usage
An instance of JoshuaEstes\Component\FeatureToggle\FeatureContainer
initialized with features defined in the package config is available through the Facade FeatureContainerFacade
, the alias FeatureContainer
or through the laravel-feature-toggle
service in the IOC container.
Testing feature availability
FeatureContainer::hasFeature("featureName");
Testing feature enabled
$feature = FeatureContainer::getFeature("featureName"); $feature->isEnabled();
More examples
The examples above display only very basic usage of the library, for more advanced examples and detailed information on the library check the JoshuaEstes/FeatureToggle repository.