You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ConnectionManager: A datasource configuration in DATABASE_CONFIG (or passed to ConnectionManager::create()) may set its connection with a DSN in the 'dsn' key, e.g. 'dsn' => env('DATABASE_URL') with mysql://user:secret@localhost:3306/app?encoding=utf8mb4 (the CakePHP 3.x and later format). The schemes mysql, postgres / postgresql / pgsql, sqlite and sqlserver / mssql / sqlsrv select the datasource; user, password, host, port and path become login, password, host, port and database; query parameters become other keys (encoding, schema, prefix, persistent, flags[...], ...)
CakeEmail: An EmailConfig profile (or an array passed to config()) may set its transport with a DSN in the Symfony Mailer MAILER_DSN format in the 'dsn' key, e.g. 'dsn' => env('MAILER_DSN'). smtp://user:pass@host:587 uses the Smtp transport (with tls on port 587 or ?tls=1), smtps://user:pass@host connects to ssl://host on port 465, sendmail://default and native://default use the Mail transport and null://null uses the Debug transport
Precedence: For both, the keys parsed from the DSN replace the same keys of the array and the other keys are kept, as in CakePHP 3.x and later. An empty 'dsn' (null, '' or false) is ignored, so the array keys apply when the environment variable is not set. The 'dsn' key is removed from the resulting configuration. Errors name the configuration and never contain the user name or password
DSN class maps: ConnectionManager and CakeEmail have setDsnClassMap() and getDsnClassMap(), as in CakePHP 3.x and later, so plugins can add schemes or replace built-in ones (e.g. in their Config/bootstrap.php). A value is a class name in plugin dot syntax ('mydb' => 'MyPlugin.Database/MyDb'), whose DSN parts become the usual keys of a datasource or transport, or a callable function (array $parts, array $config): array that returns the configuration keys, so a plugin can map Symfony style DSNs such as ses+api://KEY:SECRET@default?region=eu-west-1 to its own options. null removes a scheme
parseDsn(): New public static methods ConnectionManager::parseDsn() and CakeEmail::parseDsn() that turn a DSN into configuration keys
CakeDsn: New utility class with the DSN parser shared by both. User info, host and path are URL-decoded