Error using Middleware on Laravel/Lumen

Asked

Viewed 130 times

1

Personal talk I’m making the following mistake:

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,
]);
  • Which version of Lumen you are using?

  • Laravel Lumen 5.6.1

1 answer

1


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

In Lumen 5.6 this section of middleware is that way:

/*
|--------------------------------------------------------------------------
| 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 commenting on these middleware and see if it works. Also check the upgrade guide if there is any further change.

  • Thank you very much gmsantos, solved the problem.

  • @Eltonsilva that good! Mark the answer as accepted is also a good sign of thanks. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.