Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
thannaske authored Jan 19, 2022
1 parent 34be8ff commit 518e974
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ FEATURE_FOURTH_TEST=false
```

### Direct usage

You can directly access the package's methods as following.

```php
Expand All @@ -42,18 +43,35 @@ 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
```php
// 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.

### Blade

Furthermore, you can use conditional Blade directives to render content based on the state of a given feature flag.

```blade
@feature('registration')
<a href="/register">Register</a>
@endfeature
```

```blade
@unlessfeature('onPremise')
...
@endunlessfeature
```

## Testing

```bash
Expand All @@ -70,7 +88,7 @@ Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

## Security Vulnerabilities

Please report security vulnerabilities directly to the maintainer. You can find contact information on their GitHub profile.
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

## Credits

Expand Down

0 comments on commit 518e974

Please sign in to comment.