{"record":{"id":"ab7981240e83edfb","repo":"laravel/framework","slug":"unsupported-driver-config-driver","errorCode":null,"errorMessage":"Unsupported driver [{$config['driver']}].","messagePattern":"Unsupported driver \\[(.+?)\\]\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Connectors/ConnectionFactory.php","lineNumber":286,"sourceCode":"     * @throws \\InvalidArgumentException\n     */\n    public function createConnector(array $config)\n    {\n        if (! isset($config['driver'])) {\n            throw new InvalidArgumentException('A driver must be specified.');\n        }\n\n        if ($this->container->bound($key = \"db.connector.{$config['driver']}\")) {\n            return $this->container->make($key);\n        }\n\n        return match ($config['driver']) {\n            'mysql' => new MySqlConnector,\n            'mariadb' => new MariaDbConnector,\n            'pgsql' => new PostgresConnector,\n            'sqlite' => new SQLiteConnector,\n            'sqlsrv' => new SqlServerConnector,\n            default => throw new InvalidArgumentException(\"Unsupported driver [{$config['driver']}].\"),\n        };\n    }\n\n    /**\n     * Create a new connection instance.\n     *\n     * @param  string  $driver\n     * @param  \\PDO|\\Closure  $connection\n     * @param  string  $database\n     * @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)) {","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Connectors/ConnectionFactory.php#L268-L304","documentation":"Thrown by ConnectionFactory::createConnector() in the match expression's default arm. The 'driver' value is present but not one of mysql/mariadb/pgsql/sqlite/sqlsrv, and no custom connector is registered in the container under db.connector.<driver>. The factory will only build connectors for drivers it knows or that were explicitly bound.","triggerScenarios":"A config with 'driver' => 'mongo' (or any typo such as 'myslq', 'postgre', 'sqlite3'); using a custom driver without first binding db.connector.<driver> in the container; referencing a driver whose PHP extension (pdo_mysql, pdo_pgsql) is not loaded so it was never registered.","commonSituations":"Typos in DB_CONNECTION; missing PHP PDO extension causing the driver to be unsupported; attempting to use a package-provided driver before its service provider (which binds the connector) is registered.","solutions":["Correct the driver name: 'mysql', 'mariadb', 'pgsql', 'sqlite', or 'sqlsrv'.","Install/enable the matching PDO extension (e.g. pdo_mysql, pdo_pgsql) and restart PHP.","For a custom driver, bind it before opening the connection: $this->app->bind('db.connector.mydriver', MyConnector::class).","Ensure any third-party database package's service provider is registered in config/app.php."],"exampleFix":"// before\n// .env: DB_CONNECTION=myslq\n\n// after\n// .env: DB_CONNECTION=mysql","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['mysql', 'mariadb', 'pgsql', 'sqlite', 'sqlsrv'];\nif (! in_array($config['driver'] ?? null, SUPPORTED, true)\n    && ! app()->bound(\"db.connector.{$config['driver']}\")) {\n    throw new \\InvalidArgumentException('Unsupported DB driver: '.($config['driver'] ?? '(none)'));\n}","typeGuard":"function isSupportedDriver(string $driver): bool {\n    return in_array($driver, ['mysql', 'mariadb', 'pgsql', 'sqlite', 'sqlsrv'], true);\n}","tryCatchPattern":null,"preventionTips":["Restrict DB_CONNECTION to one of the supported driver strings.","Ensure the matching PDO extension is installed (pdo_mysql, pdo_pgsql, etc.).","Register custom connector bindings before opening a custom driver connection."],"tags":["database","configuration","driver","laravel"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}