Laravel say that Auth guard [] is not defined

Posted by

Error:

 Auth guard [web] is not defined. {"exception":"[object] (InvalidArgumentException(code: 0): Auth guard [web] is not defined. at C:\\xampp\\htdocs\\myhospitalnow\\mhn-colleges-ms\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php:86)

Sulotion:

Step 1: Define the web Guard in config/auth.php

Open the config/auth.php file in your Laravel project and make sure that the guards array includes a web guard definition. It should look something like this:

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'passport', // or 'token' if you're not using Laravel Passport
        'provider' => 'users',
        'hash' => false,
    ],
],

Step 2: Ensure the providers Array Is Correctly Set Up

In the same config/auth.php file, ensure that the providers array includes a definition for users:

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Models\User::class,
    ],

    // 'users' => [
    //     'driver' => 'database',
    //     'table' => 'users',
    // ],
],

Step 3: Clear the Configuration Cache

php artisan config:clear
php artisan cache:clear
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x