Prior to this change, Drupal's installer only found database drivers in the Drupal\Core and Drupal\Driver namespaces. This meant that contrib modules that provide database drivers would need to instruct site owners to copy the driver files into the website's /drivers directory.
Now, the installer also finds database drivers in the Drupal\{$module_name}\Driver namespace. For contrib modules that place their database drivers into this namespace, site owners can install the module as they would any other module, without needing to copy driver files elsewhere.
Specifically, the new location where the installer looks is every module's MODULE_ROOT/src/Driver/Database/{$driver_name} directory. Driver class files within this directory are required to be in the Drupal\{$module_name}\Driver\Database\{$driver_name} namespace.
For maintainers for contrib/custom database drivers
Database drivers can now be placed in a module and therefore need a {module}.info.yml in order to be discovered.
Existing custom and contributed database drivers that tell users to copy the driver to DRUPAL_ROOT/drivers will continue to work as before. However, it is recommended that they consider updating to take advantage of this change. To do that move the driver to src/Driver/Database/ and set the namespace to Drupal\{$module_name}\Driver\Database\{$driver_name}.
API additions
- An optional $namespace parameter added to
db_installer_object(). - A new static method
Drupal\Core\Database\Database::findDriverAutoloadDirectory()added. - For database drivers in a module's namespace (as opposed to in Drupal\Driver or Drupal\Core), a
modulequery parameter is added to the database connection URL. For example:pgsql://test_user:test_pass@test_host:5432/test_database?module=driver_test. URLs for database drivers in the Drupal\Driver and Drupal\Core namespaces are unaffected. - For database drivers in a module's namespace (as opposed to in Drupal\Driver or Drupal\Core), an
'autoload'key is added to the database connection array in settings.php. Setting it is required (and done automatically by the installer when it writes the settings.php file) if using a database driver from a module's namespace unless the Drupal site is using Composer and the driver's namespace is in Composer's autoloader. Setting it is not required for drivers in the Drupal\Driver and Drupal\Core namespaces.