Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
thannaske committed Jan 18, 2022
2 parents b560948 + 7b06592 commit 488c648
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- First release

Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Rescaled\SimpleFeature\Tests;

use Illuminate\Database\Eloquent\Factories\Factory;
use Orchestra\Testbench\TestCase as Orchestra;
use Rescaled\SimpleFeature\SimpleFeatureServiceProvider;

Expand Down

0 comments on commit 488c648

Please sign in to comment.