From c504dbf65c27c36a7b827dd62e2677c8798e55d6 Mon Sep 17 00:00:00 2001 From: thannaske Date: Mon, 17 Jan 2022 22:33:45 +0000 Subject: [PATCH 1/3] Fix styling --- tests/TestCase.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 9f022e8..cc0c543 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,7 +2,6 @@ namespace Rescaled\SimpleFeature\Tests; -use Illuminate\Database\Eloquent\Factories\Factory; use Orchestra\Testbench\TestCase as Orchestra; use Rescaled\SimpleFeature\SimpleFeatureServiceProvider; From 0e5192c2ec2071c7f7461f57337b2e1785de68e3 Mon Sep 17 00:00:00 2001 From: thannaske Date: Mon, 17 Jan 2022 22:50:18 +0000 Subject: [PATCH 2/3] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63e9cc1..fd7624b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `simple-feature` will be documented in this file. +## v1.0.0 - 2022-01-17 + +Initial release + ## 1.0.0 - 2022-01-17 - initial release From 7b065929c6953bb7a39fbbcac1eef72607ba7eaf Mon Sep 17 00:00:00 2001 From: Tobias <8004696+thannaske@users.noreply.github.com> Date: Mon, 17 Jan 2022 23:54:55 +0100 Subject: [PATCH 3/3] Update README.md (docs) Improve documentation of how to use the package --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 06633c9..b53e0f4 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,9 @@ composer require rescaled/simple-feature ## Usage +### Define feature flags +Feature flags are defined in your environment file. They must be defined in snake case as well as being prefixed with `FEATURE_`. + ```dotenv FEATURE_FIRST_TEST=true FEATURE_SECOND_TEST=true @@ -26,6 +29,9 @@ FEATURE_THIRD_TEST=false FEATURE_FOURTH_TEST=false ``` +### Direct usage +You can directly access the package's methods as following. + ```php SimpleFeature::enabled('firstTest') // true SimpleFeature::disabled('firstTest') // false @@ -35,6 +41,19 @@ SimpleFeature::allEnabled(['firstTest', 'thirdTest']) // false SimpleFeature::allDisabled(['firstTest', 'thirdTest']) // false ``` +### Middleware +The package comes with two middlewares that allow to check whether a given set of features is enabled or disabled. + +``` +FEATURE_REGISTRATION=true +FEATURE_ON_PREMISE=true + +Route::get('/register', [RegistrationController::class, 'create'])->middleware('feature.enabled:registration'); +Route::get('/billing', [BillingController, 'show'])->middleware('feature.disabled:onPremise'); +``` + +If the feature hasn't the desired state the middleware will abort the request with a 404. + ## Testing ```bash