{"record":{"id":"821b159748adc5e0","repo":"laravel/framework","slug":"unsupported-driver-driver","errorCode":null,"errorMessage":"Unsupported driver [{$driver}].","messagePattern":"Unsupported driver \\[(.+?)\\]\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Connectors/ConnectionFactory.php","lineNumber":314,"sourceCode":"     * @param  string  $prefix\n     * @param  array  $config\n     * @return \\Illuminate\\Database\\Connection\n     *\n     * @throws \\InvalidArgumentException\n     */\n    protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])\n    {\n        if ($resolver = Connection::getResolver($driver)) {\n            return $resolver($connection, $database, $prefix, $config);\n        }\n\n        return match ($driver) {\n            'mysql' => new MySqlConnection($connection, $database, $prefix, $config),\n            'mariadb' => new MariaDbConnection($connection, $database, $prefix, $config),\n            'pgsql' => new PostgresConnection($connection, $database, $prefix, $config),\n            'sqlite' => new SQLiteConnection($connection, $database, $prefix, $config),\n            'sqlsrv' => new SqlServerConnection($connection, $database, $prefix, $config),\n            default => throw new InvalidArgumentException(\"Unsupported driver [{$driver}].\"),\n        };\n    }\n}\n","sourceCodeStart":296,"sourceCodeEnd":318,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Connectors/ConnectionFactory.php#L296-L318","documentation":"Thrown by ConnectionFactory::createConnection() in the match default arm. Unlike createConnector, this checks Connection::getResolver($driver) first (custom resolvers registered via Connection::resolveUsing), then falls through to the known match list (mysql/mariadb/pgsql/sqlite/sqlsrv). If neither matches, the driver cannot be mapped to a Connection class.","triggerScenarios":"A connector was successfully resolved (e.g. via a container binding db.connector.<driver>) but no corresponding Connection class/resolver exists. Typical when a package registers a connector but forgets to register a Connection via Connection::resolveUsing, or when a custom driver name passes the connector step but not the connection step.","commonSituations":"Building a custom database driver: connector is bound but the Connection resolver is not; version mismatch between a package and framework where a driver was renamed (e.g. 'mariadb' support added later); typos after binding only one half.","solutions":["Register a Connection resolver for the driver: \\Illuminate\\Database\\Connection::resolveUsing('mydriver', fn ($connection, $database, $prefix, $config) => new MyConnection($connection, $database, $prefix, $config)).","Confirm the driver name matches one of the built-ins if you did not intend a custom connection.","If a third-party package provides the driver, ensure both its connector binding and Connection resolver are registered (check its ServiceProvider boot).","Upgrade/align package versions so mariadb/other drivers are supported by your framework version."],"exampleFix":"// before\n$this->app->bind('db.connector.mydriver', MyConnector::class);\n// Connection resolver never registered -> createConnection() throws\n\n// after\n$this->app->bind('db.connector.mydriver', MyConnector::class);\n\\Illuminate\\Database\\Connection::resolveUsing('mydriver', fn ($c, $db, $prefix, $config) => new MyConnection($c, $db, $prefix, $config));","handlingStrategy":"validation","validationCode":"$driver = $config['driver'] ?? null;\n$supported = ['mysql', 'mariadb', 'pgsql', 'sqlite', 'sqlsrv'];\nif (! in_array($driver, $supported, true)\n    && \\Illuminate\\Database\\Connection::getResolver($driver) === null) {\n    \\Illuminate\\Database\\Connection::resolveUsing($driver, fn ($c, $db, $p, $cfg) => new MyConnection($c, $db, $p, $cfg));\n}","typeGuard":"function hasConnectionResolver(string $driver): bool {\n    return \\Illuminate\\Database\\Connection::getResolver($driver) !== null\n        || in_array($driver, ['mysql', 'mariadb', 'pgsql', 'sqlite', 'sqlsrv'], true);\n}","tryCatchPattern":null,"preventionTips":["When building a custom driver, always register both the connector binding and a Connection resolver.","Keep package versions aligned so newly-added drivers (e.g. mariadb) are supported by your framework.","Centralize driver registration in a service provider so neither half is forgotten."],"tags":["database","configuration","driver","connection","laravel"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}