ConnectionConfig class final

A single named connection (config/database.php parity).

Constructors

ConnectionConfig({required String driver, required String database, String? host, int? port, String? username, String? password, Map<String, Object?> options = const <String, Object?>{}})
const
ConnectionConfig.fromUrl(String url, {String basePath = '.'})
A connection from a URL, as Laravel's DB_URL: pgsql://user:secret@host:5432/app?sslmode=require&pool=5, mysql://user@host/app, mariadb://..., sqlite:database/app.sqlite or sqlite::memory:. User and password are URL-decoded; a relative SQLite path resolves against basePath.
factory

Properties

database → String
final
driver → String
final
hashCode → int
The hash code for this object.
no setterinherited
host → String?
final
options → Map<String, Object?>
final
password → String?
final
port → int?
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
username → String?
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toMap() → Map<String, Object?>
toString() → String
A string representation of this object.
inherited
withUrl(String url, {String basePath = '.'}) → ConnectionConfig
This connection with what url gives, merged as Laravel 12's ConfigurationUrlParser does for DB_URL: the scheme sets the driver (postgres/postgresql → pgsql, mysql2 → mysql, sqlite3 → sqlite), the host, port, user, password and database it contains replace this connection's, and its query string adds options. Parts the URL leaves out keep their values.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

redactUrl(String url) → String
url with its password masked, for messages: the error of a malformed DB_URL reaches doctor's output, the boot log and error trackers, where user:secret@ must not.