laravel/framework · error · InvalidArgumentException
Auth driver [ ] for guard [ ] is not defined.
Error message
Auth driver [{$config['driver']}] for guard [{$name}] is not defined. What it means
Thrown by AuthManager::resolve() when a guard's config exists but its 'driver' value matches neither a registered custom creator nor a create{Driver}Driver method on the manager. The driver name is the strategy used to build the guard (session, token, sanctum, etc.), and unknown values cannot be resolved to a guard implementation.
Solutions
- Use a built-in driver that exists (session for web guards, token for API token guards).
- Install/enable the package that provides the driver (e.g. composer require laravel/sanctum and ensure its ServiceProvider is registered).
- Register a custom driver with Auth::extend('mydriver', fn (...) => new MyGuard(...)) before the guard is resolved.
- Fix the typo in the 'driver' key of the guard config.
- Run php artisan config:clear to drop a stale cached config.
Example fix
// before
'guards' => [
'api' => ['driver' => 'sanctum', 'provider' => 'users'], // Sanctum not installed
],
// after — install and register the package, or switch driver
'guards' => [
'api' => ['driver' => 'session', 'provider' => 'users'],
],
// then: composer require laravel/sanctum && php artisan install:api Defensive patterns
Strategy: validation
Validate before calling
// PHP — confirm the driver is resolvable
$name = 'api';
$cfg = config("auth.guards.{$name}");
$driver = $cfg['driver'] ?? null;
$method = 'create' . ucfirst((string) $driver) . 'Driver';
$builtIn = in_array($driver, ['session','token'], true);
$resolvable = $builtIn || method_exists(app(\Illuminate\Auth\AuthManager::class), $method) || app(\Illuminate\Auth\AuthManager::class)->hasCustomCreator($driver);
if (! $resolvable) abort(500, "Auth driver [{$driver}] is not supported."); Type guard
function authDriverIsResolvable(string $driver): bool {
return in_array($driver, ['session','token'], true)
|| method_exists(app(\Illuminate\Auth\AuthManager::class), 'create' . ucfirst($driver) . 'Driver');
} Try / catch
try {
Auth::guard('api');
} catch (\InvalidArgumentException $e) {
report('Auth driver not resolvable: '.$e->getMessage());
throw $e;
} Prevention
- Install packages that provide custom drivers before referencing them.
- Register custom drivers in a non-deferred service provider's boot().
- Use 'session' or 'token' unless a custom driver is wired.
When it happens
Trigger: Defining a guard in auth.php with a 'driver' value that is not one of the built-ins (session/token) and is not registered via Auth::extend(); misspelling a driver like 'sesion'; using a package (e.g. Sanctum/Passport) that is not installed or booted.
Common situations: Removing Laravel Sanctum without updating guards still set to driver 'sanctum'; a typo in the driver string; referencing a custom driver before Auth::extend() runs in a service provider; config cache predating the package installation.
Related errors
- Auth guard [ ] is not defined.
- A driver must be specified.
- Authentication user provider
- Driver [ ] is not supported.
- Password resetter [ ] is not defined.
AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11).
Data as JSON: /api/errors/4df788966fde45f2.
Report an issue: GitHub.
Appendix: source
Thrown at src/Illuminate/Auth/AuthManager.php:103
protected function resolve($name)
{
$config = $this->getConfig($name);
if (is_null($config)) {
throw new InvalidArgumentException("Auth guard [{$name}] is not defined.");
}
if (isset($this->customCreators[$config['driver']])) {
return $this->callCustomCreator($name, $config);
}
$driverMethod = 'create'.ucfirst($config['driver']).'Driver';
if (method_exists($this, $driverMethod)) {
return $this->{$driverMethod}($name, $config);
}
throw new InvalidArgumentException(
"Auth driver [{$config['driver']}] for guard [{$name}] is not defined."
);
}
/**
* Call a custom driver creator.
*
* @param string $name
* @param array $config
* @return mixed
*/
protected function callCustomCreator($name, array $config)
{
return $this->customCreators[$config['driver']]($this->app, $name, $config);
}
/**
* Create a session based authentication guard.View on GitHub (pinned to e0f6eb3518)