Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel: Authentication user provider [] is not defined

I am trying to build a simple website which will have no user management.

I am using the database driver for both cache and sessions.

I have removed all the user-related boilerplate code that Laravel came with, but I keep getting the error message in the title.

This is my config/auth.php:

return [

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],

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

        'api' => [
            'driver' => 'token',
            'provider' => 'users',
        ],
    ],

    'providers' => [
        'users' => [],
    ],

    'passwords' => [
        'users' => [],
    ],

];

Is it possible to have no user providers defined if one intends to not support users on his website?

EDIT 1: After disabling the Illuminate\Auth\AuthServiceProvider service provider, I get the following exception:

ReflectionException thrown with message "Class auth.driver does not exist"

> Stacktrace:
> #16 ReflectionException in vendor\laravel\framework\src\Illuminate\Container\Container.php:752
> #15 ReflectionClass:__construct in vendor\laravel\framework\src\Illuminate\Container\Container.php:752
> #14 Illuminate\Container\Container:build in vendor\laravel\framework\src\Illuminate\Container\Container.php:631
> #13 Illuminate\Container\Container:resolve in vendor\laravel\framework\src\Illuminate\Container\Container.php:586
> #12 Illuminate\Container\Container:make in vendor\laravel\framework\src\Illuminate\Foundation\Application.php:732
> #11 Illuminate\Foundation\Application:make in vendor\laravel\framework\src\Illuminate\Session\DatabaseSessionHandler.php:213
> #10 Illuminate\Session\DatabaseSessionHandler:userId in vendor\laravel\framework\src\Illuminate\Session\DatabaseSessionHandler.php:200
> #9 Illuminate\Session\DatabaseSessionHandler:addUserInformation in vendor\laravel\framework\src\Illuminate\Session\DatabaseSessionHandler.php:186
> #8 Illuminate\Session\DatabaseSessionHandler:Illuminate\Session\{closure}
> in vendor\laravel\framework\src\Illuminate\Support\helpers.php:1035
> #7 tap in vendor\laravel\framework\src\Illuminate\Session\DatabaseSessionHandler.php:188
> #6 Illuminate\Session\DatabaseSessionHandler:getDefaultPayload in vendor\laravel\framework\src\Illuminate\Session\DatabaseSessionHandler.php:125
> #5 Illuminate\Session\DatabaseSessionHandler:write in vendor\laravel\framework\src\Illuminate\Session\Store.php:128
> #4 Illuminate\Session\Store:save in vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php:87
> #3 Illuminate\Session\Middleware\StartSession:terminate in vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:218
> #2 Illuminate\Foundation\Http\Kernel:terminateMiddleware in vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:189
> #1 Illuminate\Foundation\Http\Kernel:terminate in public\index.php:60
> #0 require_once in server.php:21
like image 853
Genti Saliu Avatar asked Dec 10 '25 11:12

Genti Saliu


1 Answers

You likely need to comment out the AuthServiceProvider in config/app.php:

'providers' => [

    /*
     * Laravel Framework Service Providers...
     */
    Illuminate\Auth\AuthServiceProvider::class,  // COMMENT THIS OUT

If you post your whole stack trace we could confirm where this error is coming from

like image 182
Jeff Avatar answered Dec 12 '25 02:12

Jeff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!