{"id":"bea9b9c431f53876","repo":"laravel/framework","slug":"authentication-user-provider-driver-is-not-de","errorCode":null,"errorMessage":"Authentication user provider [{$driver}] is not defined.","messagePattern":"Authentication user provider \\[(.+?)\\] is not defined\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Auth/CreatesUserProviders.php","lineNumber":39,"sourceCode":"     *\n     * @throws \\InvalidArgumentException\n     */\n    public function createUserProvider($provider = null)\n    {\n        if (is_null($config = $this->getProviderConfiguration($provider))) {\n            return;\n        }\n\n        if (isset($this->customProviderCreators[$driver = ($config['driver'] ?? null)])) {\n            return call_user_func(\n                $this->customProviderCreators[$driver], $this->app, $config\n            );\n        }\n\n        return match ($driver) {\n            'database' => $this->createDatabaseProvider($config),\n            'eloquent' => $this->createEloquentProvider($config),\n            default => throw new InvalidArgumentException(\n                \"Authentication user provider [{$driver}] is not defined.\"\n            ),\n        };\n    }\n\n    /**\n     * Get the user provider configuration.\n     *\n     * @param  string|null  $provider\n     * @return array|null\n     */\n    protected function getProviderConfiguration($provider)\n    {\n        if ($provider = $provider ?: $this->getDefaultUserProvider()) {\n            return $this->app['config']['auth.providers.'.$provider];\n        }\n    }\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Auth/CreatesUserProviders.php#L21-L57","documentation":"Thrown by CreatesUserProviders::createUserProvider() when the provider's 'driver' is neither 'database' nor 'eloquent' and no custom provider creator was registered with Auth::provider(). The guard references a user provider that the framework cannot build.","triggerScenarios":"Setting auth.providers.{name}.driver to an unregistered value (e.g. 'mongo') while a guard's 'provider' key points to it; calling Auth::createUserProvider('missing') directly.","commonSituations":"Removing/renaming a provider driver in config; using a custom user source without registering Auth::provider('custom', ...) in a service provider; stale cached config after an edit.","solutions":["Register the custom provider: Auth::provider('custom', fn ($app, array $config) => new CustomUserProvider(...)).","Use the built-in 'eloquent' (with a 'model') or 'database' (with a 'table') driver.","Confirm auth.guards.{guard}.provider matches a real key under auth.providers.","Run php artisan config:clear after editing config/auth.php."],"exampleFix":"// before - config/auth.php\n'providers' => [\n    'users' => ['driver' => 'mongo', 'model' => App\\Models\\User::class],\n],\n\n// after\n'providers' => [\n    'users' => ['driver' => 'eloquent', 'model' => App\\Models\\User::class],\n],\n// or register in a provider: Auth::provider('mongo', fn ($app, $config) => new MongoUserProvider(...));","handlingStrategy":"validation","validationCode":"$provider = config('auth.guards.web.provider');\n$driver = config(\"auth.providers.{$provider}.driver\");\nif (! in_array($driver, ['eloquent', 'database'], true) && ! array_key_exists($driver, $customProviders)) {\n    throw new RuntimeException(\"User provider driver [{$driver}] is not registered.\");\n}","typeGuard":"function userProviderDriverIsSupported(string $driver): bool\n{\n    return in_array($driver, ['eloquent', 'database'], true);\n}","tryCatchPattern":"try {\n    Auth::createUserProvider($name);\n} catch (\\InvalidArgumentException $e) {\n    // fall back to eloquent or abort config bootstrap\n}","preventionTips":["Register custom user providers with Auth::provider() before any guard resolves them.","Validate the providers block in config/auth.php during a deploy health check.","Keep provider driver names in a single constant list referenced by config and tests."],"tags":["authentication","configuration","user-provider","laravel"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}