|
6 | 6 | - [Global Middleware](#global-middleware)
|
7 | 7 | - [Assigning Middleware To Routes](#assigning-middleware-to-routes)
|
8 | 8 | - [Middleware Groups](#middleware-groups)
|
| 9 | + - [Sorting Middleware](sorting-middleware) |
9 | 10 | - [Middleware Parameters](#middleware-parameters)
|
10 | 11 | - [Terminable Middleware](#terminable-middleware)
|
11 | 12 |
|
@@ -185,6 +186,27 @@ Middleware groups may be assigned to routes and controller actions using the sam
|
185 | 186 |
|
186 | 187 | > {tip} Out of the box, the `web` middleware group is automatically applied to your `routes/web.php` file by the `RouteServiceProvider`.
|
187 | 188 |
|
| 189 | +<a name="sorting-middleware"></a> |
| 190 | +### Sorting Middleware |
| 191 | + |
| 192 | +In some cases you'd want to run your middleware in a specific order. You can achieve this by ordering the middleware with the `$middlewarePriority` property of your HTTP kernel. This doesn't includes global middleware which is always run before other middlewares. |
| 193 | + |
| 194 | + /** |
| 195 | + * The priority-sorted list of middleware. |
| 196 | + * |
| 197 | + * This forces non-global middleware to always be in the given order. |
| 198 | + * |
| 199 | + * @var array |
| 200 | + */ |
| 201 | + protected $middlewarePriority = [ |
| 202 | + \Illuminate\Session\Middleware\StartSession::class, |
| 203 | + \Illuminate\View\Middleware\ShareErrorsFromSession::class, |
| 204 | + \App\Http\Middleware\Authenticate::class, |
| 205 | + \Illuminate\Session\Middleware\AuthenticateSession::class, |
| 206 | + \Illuminate\Routing\Middleware\SubstituteBindings::class, |
| 207 | + \Illuminate\Auth\Middleware\Authorize::class, |
| 208 | + ]; |
| 209 | + |
188 | 210 | <a name="middleware-parameters"></a>
|
189 | 211 | ## Middleware Parameters
|
190 | 212 |
|
|
0 commit comments