{"record":{"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/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/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 has been registered via Auth::provider(). User providers are the backends that retrieve user records (Eloquent model, DB query builder, etc.).","triggerScenarios":"Configuring a guard's 'provider' to a key whose entry in config/auth.php 'providers' uses an unknown 'driver'; referencing a custom provider driver before calling Auth::provider($driver, $callback).","commonSituations":"Typo in provider driver ('eloquen'); removing a package that registered a custom user provider; config cache from before a custom provider was registered in a service provider; pointing a guard at a provider that was deleted from auth.php.","solutions":["Set the provider's driver to 'eloquent' (with a 'model') or 'database' (with a 'table').","Register the custom provider via Auth::provider('mydriver', fn ($app, $config) => new MyUserProvider(...)) before it is resolved.","Verify the guard's 'provider' key matches an entry under 'providers' in auth.php.","Run php artisan config:clear to drop a stale cached config."],"exampleFix":"// before\n'providers' => [\n    'users' => ['driver' => 'mydriver', 'model' => User::class], // not registered\n],\n\n// after — register in AuthServiceProvider::boot()\nAuth::provider('mydriver', function ($app, array $config) {\n    return new MyUserProvider($app['hash'], $config['model']);\n});\n// or switch to a built-in driver:\n'providers' => [\n    'users' => ['driver' => 'eloquent', 'model' => User::class],\n],","handlingStrategy":"validation","validationCode":"// PHP — verify the provider driver before resolving\n$providerKey = config('auth.guards.web.provider');\n$providerCfg = config(\"auth.providers.{$providerKey}\");\n$driver = $providerCfg['driver'] ?? null;\n$ok = in_array($driver, ['eloquent','database'], true) || app()->bound(\"auth.provider.creator.{$driver}\");\nif (! $ok) abort(500, \"User provider driver [{$driver}] is not defined.\");","typeGuard":"function providerDriverIsRegistered(?string $driver): bool {\n    return in_array($driver, ['eloquent','database'], true);\n}","tryCatchPattern":"try {\n    Auth::createUserProvider($provider);\n} catch (\\InvalidArgumentException $e) {\n    report('Unknown user provider driver: '.$e->getMessage());\n    throw $e;\n}","preventionTips":["Use 'eloquent' or 'database' providers unless a custom one is registered.","Register custom providers via Auth::provider() before resolution.","Clear config cache after editing auth.php."],"tags":["authentication","user-provider","laravel","configuration"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}