laravel/framework · error · InvalidArgumentException
Unsupported driver [ ].
Error message
Unsupported driver [{$driver}]. What it means
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.
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.
Example fix
// before
$this->app->bind('db.connector.mydriver', MyConnector::class);
// Connection resolver never registered -> createConnection() throws
// after
$this->app->bind('db.connector.mydriver', MyConnector::class);
\Illuminate\Database\Connection::resolveUsing('mydriver', fn ($c, $db, $prefix, $config) => new MyConnection($c, $db, $prefix, $config)); Defensive patterns
Strategy: validation
Validate before calling
$driver = $config['driver'] ?? null;
$supported = ['mysql', 'mariadb', 'pgsql', 'sqlite', 'sqlsrv'];
if (! in_array($driver, $supported, true)
&& \Illuminate\Database\Connection::getResolver($driver) === null) {
\Illuminate\Database\Connection::resolveUsing($driver, fn ($c, $db, $p, $cfg) => new MyConnection($c, $db, $p, $cfg));
} Type guard
function hasConnectionResolver(string $driver): bool {
return \Illuminate\Database\Connection::getResolver($driver) !== null
|| in_array($driver, ['mysql', 'mariadb', 'pgsql', 'sqlite', 'sqlsrv'], true);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- A driver must be specified.
- Database hosts array is empty.
- Lost connection and no reconnector available.
- Unsupported driver [ ].
- Auth driver [ ] for guard [ ] is not defined.
AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11).
Data as JSON: /api/errors/821b159748adc5e0.
Report an issue: GitHub.
Appendix: source
Thrown at src/Illuminate/Database/Connectors/ConnectionFactory.php:314
* @param string $prefix
* @param array $config
* @return \Illuminate\Database\Connection
*
* @throws \InvalidArgumentException
*/
protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
{
if ($resolver = Connection::getResolver($driver)) {
return $resolver($connection, $database, $prefix, $config);
}
return match ($driver) {
'mysql' => new MySqlConnection($connection, $database, $prefix, $config),
'mariadb' => new MariaDbConnection($connection, $database, $prefix, $config),
'pgsql' => new PostgresConnection($connection, $database, $prefix, $config),
'sqlite' => new SQLiteConnection($connection, $database, $prefix, $config),
'sqlsrv' => new SqlServerConnection($connection, $database, $prefix, $config),
default => throw new InvalidArgumentException("Unsupported driver [{$driver}]."),
};
}
}
View on GitHub (pinned to e0f6eb3518)