Error when using Middleware in Laravel / Lumen

1

Personally I have the following error:

ReflectionException
Class Illuminate\Cookie\Middleware\EncryptCookies does not exist

I'm using Lumen but I think I may have set something wrong in the app.php:

$app->middleware([
   Illuminate\Cookie\Middleware\EncryptCookies::class,
   Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
   Illuminate\Session\Middleware\StartSession::class,
   Illuminate\View\Middleware\ShareErrorsFromSession::class,
   //Illuminate\Cookie\Middleware\EncryptCookies::class,
]);

$app->routeMiddleware([
//     'auth' => App\Http\Middleware\Authenticate::class,
]);
    
asked by anonymous 06.03.2018 / 20:09

1 answer

1

It seems to me that these middlewares listed existed only in version 5.0 of bootstrap/app.php and were removed in later versions.

In Lumen 5.6 this section of middlewares looks like this:

/*
|--------------------------------------------------------------------------
| Register Middleware
|--------------------------------------------------------------------------
|
| Next, we will register the middleware with the application. These can
| be global middleware that run before and after each request into a
| route or middleware that'll be assigned to some specific routes.
|
*/
// $app->middleware([
//    App\Http\Middleware\ExampleMiddleware::class
// ]);
// $app->routeMiddleware([
//     'auth' => App\Http\Middleware\Authenticate::class,
// ]);

Try to comment on these middlewares and see if it works. Also check upgrade guide if there is any other change.

    
07.03.2018 / 13:59