{"id":"4df788966fde45f2","repo":"laravel/framework","slug":"auth-driver-config-driver-for-guard-nam","errorCode":null,"errorMessage":"Auth driver [{$config['driver']}] for guard [{$name}] is not defined.","messagePattern":"Auth driver \\[(.+?)\\] for guard \\[(.+?)\\] is not defined\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Auth/AuthManager.php","lineNumber":103,"sourceCode":"    protected function resolve($name)\n    {\n        $config = $this->getConfig($name);\n\n        if (is_null($config)) {\n            throw new InvalidArgumentException(\"Auth guard [{$name}] is not defined.\");\n        }\n\n        if (isset($this->customCreators[$config['driver']])) {\n            return $this->callCustomCreator($name, $config);\n        }\n\n        $driverMethod = 'create'.ucfirst($config['driver']).'Driver';\n\n        if (method_exists($this, $driverMethod)) {\n            return $this->{$driverMethod}($name, $config);\n        }\n\n        throw new InvalidArgumentException(\n            \"Auth driver [{$config['driver']}] for guard [{$name}] is not defined.\"\n        );\n    }\n\n    /**\n     * Call a custom driver creator.\n     *\n     * @param  string  $name\n     * @param  array  $config\n     * @return mixed\n     */\n    protected function callCustomCreator($name, array $config)\n    {\n        return $this->customCreators[$config['driver']]($this->app, $name, $config);\n    }\n\n    /**\n     * Create a session based authentication guard.","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Auth/AuthManager.php#L85-L121","documentation":"Thrown by AuthManager::resolve() when the guard config exists but its 'driver' value does not map to a create{Driver}Driver method and no custom creator was registered via Auth::extend(). Built-in drivers are 'session' and 'token'.","triggerScenarios":"Setting auth.guards.api.driver to 'jwt' (or 'passport', 'sanctum') without first registering it; a typo such as 'sesssion'; referencing a driver provided by a package that was not installed or whose AuthServiceProvider boot no longer runs.","commonSituations":"Using a third-party guard (JWT, Sanctum stateful, custom SSO) and forgetting Auth::extend('jwt', ...) in a service provider; copying a config that references a driver from a different project.","solutions":["Register the custom driver with Auth::extend('yourDriver', fn (...) => ...) in a boot() method.","Use a supported built-in driver ('session' or 'token') if no custom logic is needed.","Ensure the package providing the driver is installed and its ServiceProvider is registered in config/app.php (or bootstrap/providers.php).","Correct any typo in the driver string and run config:clear."],"exampleFix":"// before\n'guards' => [\n    'api' => ['driver' => 'jwt', 'provider' => 'users'],\n],\n// throws: Auth driver [jwt] ... is not defined\n\n// after - in AuthServiceProvider::boot()\nAuth::extend('jwt', function ($app, $name, array $config) {\n    return new JwtGuard($app['tymon.jwt'], $app['request']);\n});","handlingStrategy":"validation","validationCode":"$driver = config(\"auth.guards.{$guard}.driver\");\n$supported = in_array($driver, ['session', 'token'], true);\nif (! $supported && ! Auth::getProvider(/* via extend registry */)) {\n    throw new RuntimeException(\"Auth driver [{$driver}] is not registered.\");\n}","typeGuard":"function authDriverIsSupported(string $driver): bool\n{\n    return in_array($driver, ['session', 'token'], true)\n        || app()->bound('auth.custom-creators') && array_key_exists($driver, app('auth.custom-creators') ?? []);\n}","tryCatchPattern":"try {\n    Auth::guard($name);\n} catch (\\InvalidArgumentException $e) {\n    if (str_contains($e->getMessage(), 'is not defined.')) {\n        // register the missing driver or fall back to session\n    }\n    throw $e;\n}","preventionTips":["Register custom drivers (Auth::extend) in a service provider boot() that always runs.","Document supported driver names and assert at boot time that referenced drivers are registered.","Use the built-in session/token drivers unless you genuinely need a custom one."],"tags":["authentication","configuration","guard","driver","laravel"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}