Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

webfuelcode's avatar

Middleware does not work on laravel 11

I had used the same code on Laravel 10 which worked well but on a different project that is built on Laravel 11, shows a database error.

When the page does not need data from the database it should not show the error, but it says table session does not exist.

I used the bootstrap/app.php

->withMiddleware(function (Middleware $middleware) {
        $middleware->alias([
            'disableInstall' => \App\Http\Middleware\CheckMigrations::class,
        ]);
    })

route:

Route::group(['prefix' => 'install', 'middleware' => 'disableInstall'], function() {
    Route::get('/', [DatabaseManagementController::class, 'dbclick'])->name('db.click');
   // other routes
});
0 likes
3 replies
TruptMan-Solutions's avatar

did you run migrations? the error simply says that table session doesn't exist. this is because , from v11 session driver is changed to 'database' from 'file' so it's necessary to have session table in your database.

2 likes
martinbean's avatar

@TruptMan-Solutions Yeah, this is the answer.

For some bizarre reason, Laravel in 11.x decided to make the drivers for things like the session, queues, etc database-based by default.

1 like

Please or to participate in this conversation.