laravel/framework · error · InvalidArgumentException
Authentication user provider [{$driver}] is not defined.
Error message
Authentication user provider [{$driver}] is not defined. What it means
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.
Source
Thrown at src/Illuminate/Auth/CreatesUserProviders.php:39
*
* @throws \InvalidArgumentException
*/
public function createUserProvider($provider = null)
{
if (is_null($config = $this->getProviderConfiguration($provider))) {
return;
}
if (isset($this->customProviderCreators[$driver = ($config['driver'] ?? null)])) {
return call_user_func(
$this->customProviderCreators[$driver], $this->app, $config
);
}
return match ($driver) {
'database' => $this->createDatabaseProvider($config),
'eloquent' => $this->createEloquentProvider($config),
default => throw new InvalidArgumentException(
"Authentication user provider [{$driver}] is not defined."
),
};
}
/**
* Get the user provider configuration.
*
* @param string|null $provider
* @return array|null
*/
protected function getProviderConfiguration($provider)
{
if ($provider = $provider ?: $this->getDefaultUserProvider()) {
return $this->app['config']['auth.providers.'.$provider];
}
}
View on GitHub (pinned to bd6b5437e6)
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.
Example fix
// before - config/auth.php
'providers' => [
'users' => ['driver' => 'mongo', 'model' => App\Models\User::class],
],
// after
'providers' => [
'users' => ['driver' => 'eloquent', 'model' => App\Models\User::class],
],
// or register in a provider: Auth::provider('mongo', fn ($app, $config) => new MongoUserProvider(...)); Defensive patterns
Strategy: validation
Validate before calling
$provider = config('auth.guards.web.provider');
$driver = config("auth.providers.{$provider}.driver");
if (! in_array($driver, ['eloquent', 'database'], true) && ! array_key_exists($driver, $customProviders)) {
throw new RuntimeException("User provider driver [{$driver}] is not registered.");
} Type guard
function userProviderDriverIsSupported(string $driver): bool
{
return in_array($driver, ['eloquent', 'database'], true);
} Try / catch
try {
Auth::createUserProvider($name);
} catch (\InvalidArgumentException $e) {
// fall back to eloquent or abort config bootstrap
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Auth guard [{$name}] is not defined.
- Auth driver [{$config['driver']}] for guard [{$name}] is not
- Password resetter [{$name}] is not defined.
- Cookie jar has not been set.
- Callback must be a callable, callback array, or a 'Class@met
AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06).
Data as JSON: /data/errors/bea9b9c431f53876.json.
Report an issue: GitHub.