Skip to content

Commit

Permalink
Document new way to register middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmypuckett committed Apr 8, 2024
1 parent 837d70e commit fa990c5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,37 @@ The package uses the [auto registration feature](https://laravel.com/docs/5.8/pa

The middleware needs to be registered with the Kernel to allow it to parse the request.

### Laravel 11 & newer

Register the HTTP Stack Middleware for the web group in `bootstrap/app.php`:

```php
->withMiddleware(function (Middleware $middleware) {
// ...
$middleware->web(append: [
// ...
\Spinen\BrowserFilter\Stack\Filter::class,
]);
// ...
})
```

Register the Route Middlewares in `bootstrap/app.php`:

```php
->withMiddleware(function (Middleware $middleware) {
// ...
$middleware->alias([
// ...
'browser.allow' => \Spinen\BrowserFilter\Route\AllowFilter::class,
'browser.block' => \Spinen\BrowserFilter\Route\BlockFilter::class,
]);
// ...
})
```

### Before Laravel 11

Register the HTTP Stack Middleware for the web group in `app/Http/Kernel.php`:

```php
Expand All @@ -66,6 +97,8 @@ Register the Route Middlewares in `app/Http/Kernel.php`:
'browser.block' => \Spinen\BrowserFilter\Route\BlockFilter::class,
```

### Page to show if blocked

Build a page with a named route to redirect blocked browsers to:

```php
Expand Down

0 comments on commit fa990c5

Please sign in to comment.