Skip to content

Commit 95467e7

Browse files
committed
TDP-1887 Improve documentation.
1 parent dff1032 commit 95467e7

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

README.md

+27-11
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,44 @@ You can install the package via Composer:
4040
composer require partechgss/laravel-feature-toggles
4141

4242
## Configuration
43-
You need to set the toggle "key" somewhere. This is usually something like a user's email address, used to decide which treatment the user gets for a particular flag. This package provides middleware that automatically sets the key based on the user's email addesss. This must be run after your authentication middleware, so, regardless of whether you use it as route or global middleware, I recommend setting the priority in your Kernel.php.
43+
### Config File
44+
Looks for `config/feature-toggle.php`. To install the default one:
45+
46+
php artisan vendor:publish
47+
48+
### Middleware
49+
You need to set the toggle "key" somewhere. This is usually something like a user's email address, used to decide which treatment the user gets for a particular flag. This package provides middleware that automatically sets the key based on the user's email addesss. This must be run after your authentication middleware, so, first make it available as route middleware and set the priority in your `app/Http/Kernel.php`.
4450

4551
use PartechGSS\Laravel\FeatureToggle\Middleware\SetFeatureToggleKeyFromUserEmail;
52+
protected $routeMiddleware = [
53+
'auth' => \App\Http\Middleware\Authenticate::class,
54+
'feature-toggle' => SetFeatureToggleKeyFromUserEmail::class,
55+
];
4656
protected $middlewarePriority = [
4757
\App\Http\Middleware\Authenticate::class,
4858
SetFeatureToggleKeyFromUserEmail::class,
4959
];
5060

51-
### Route Middleware
61+
#### Execute as Route Middleware
5262
# routes/api.php
53-
Route::middleware([
54-
'auth:api',
55-
SetFeatureToggleKeyFromUserEmail::class
56-
])->group(function() {
57-
...
63+
Route::middleware(['auth:api', 'feature-toggle'])->group(function() {
64+
...,
5865
});
5966

60-
### Global Middleware
67+
#### Execute via Route Middleware Groups
6168
# app/Http/Kernel.php
62-
protected $middleware = [
63-
...
64-
SetFeatureToggleKeyFromUserEmail::class,
69+
protected $middlewareGroups = [
70+
'web' => [
71+
...,
72+
'feature-toggle',
73+
],
74+
75+
'api' => [
76+
\Barryvdh\Cors\HandleCors::class,
77+
'throttle:60,1',
78+
'bindings',
79+
'feature-toggle',
80+
],
6581
];
6682

6783
## Testing

0 commit comments

Comments
 (0)