laravel/framework · error · InvalidArgumentException

Unsupported driver [{$driver}].

Error message

Unsupported driver [{$driver}].

What it means

Thrown by ConnectionFactory::createConnection() when the driver passed to it has no matching Connection subclass and no registered Connection::resolver. This is the connection-class counterpart to the connector error: it triggers after the PDO link was already built.

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 bd6b5437e6)

Solutions

  1. Use one of the built-in drivers (mysql, mariadb, pgsql, sqlite, sqlsrv).
  2. For a custom driver, register both halves: the connector binding AND Connection::resolver($driver, fn (...) => new YourConnection(...)).
  3. Correct the driver string typo in DB_CONNECTION / database.php.
  4. After fixing config, run php artisan config:clear.

Example fix

// before
ConnectionFactory - connector registered but no resolver; createConnection falls through.

// after
\Illuminate\Database\Connection::resolver('oci', fn ($conn, $db, $prefix, $config) => new \Acme\OracleConnection($conn, $db, $prefix, $config));
Defensive patterns

Strategy: validation

Validate before calling

$supported = ['mysql','mariadb','pgsql','sqlite','sqlsrv'];
if (! in_array($driver, $supported, true) && ! \Illuminate\Database\Connection::getResolver($driver)) {
    throw new \RuntimeException("No Connection resolver for driver [$driver].");
}

Type guard

function hasConnectionResolver(string $driver): bool {
    return \Illuminate\Database\Connection::getResolver($driver) !== null;
}

Prevention

When it happens

Trigger: createConnector() succeeded (e.g. because a 'db.connector.{driver}' binding exists or the driver is recognized), but createConnection() cannot map the same driver to a Connection class. Happens when a package registers only the connector half of a driver, or when a driver name passes the connector list but not the connection list.

Common situations: Custom driver package that registered a connector but forgot Connection::resolver('oci', fn (...) => new OracleConnection); typo'd driver; mismatch between connector bindings and connection resolvers.

Related errors


AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06). Data as JSON: /data/errors/821b159748adc5e0.json. Report an issue: GitHub.