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

hafixihe's avatar

Extra guards break application

Hi.

I created extra guards. Now all routes are not working any more. I get guard not defined error. What is wrong with this?

'defaults' => [
    'guard' => 'web',
    'passwords' => 'users',
],
'guards' => [
    'admin' => [
        'driver' => 'session',
        'provider' => 'admins',
    ],
    'student' => [
        'driver' => 'session',
        'provider' => 'student',
    ],

    'api' => [
        'driver' => 'token',
        'provider' => 'users',
        'hash' => false,
    ],
],
'providers' => [
    'admins' => [
        'driver' => 'eloquent',
        'model' => App\Admin::class,
    ],
    'students' => [
        'driver' => 'eloquent',
        'model' => App\Student::class,
    ],

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

Please help

0 likes
2 replies
bobbybouwmann's avatar
Level 88

You removed the web guard, so that's why your applications break. Make sure you add it again

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

Please or to participate in this conversation.