Score:0

How do I install the database drivers?

ru flag

I'm trying to use Drupal 9 framework, and I'm stuck when setting up the database: I get the infamous error Error: Class 'Drupal\pgsql\Driver\Database\pgsql\Connection' not found.

When looking at the Drupal Core module composer.json, I see that the module expects a drivers directory to exist under vendor/drupal:

"autoload": {
        "psr-4": {
            "Drupal\\Core\\": "lib/Drupal/Core",
            "Drupal\\Component\\": "lib/Drupal/Component",
            "Drupal\\Driver\\": "../drivers/lib/Drupal/Driver"
        },

Which seems to be confirmed by this issue:

https://www.drupal.org/node/3129492

Which clearly establishes that Database drivers are now provided by their own dedicated module.

The question is: where is this module and how can it be installed? I searched packagist for drupal/drivers but it doesn't exist.

id flag
Is this an install-time or post-install issue?
Eric MORAND avatar
ru flag
I'm starting from scratch.
id flag
I’m voting to close this question because the question does not include the precise steps that occur which lead to the error message.
Score:2
cn flag

where is this module and how can it be installed?

It's not a single module containing all the drivers - each driver has its own module, already included with core.

For Postgres that's the pgsql module (for MySQL it's mysql). That's the module you need to enable, nothing else to download.

Eric MORAND avatar
ru flag
I found them inside the Drupal core module but they are not at all located where the core module autoloader expect them. This is very strange. I'll update my question.
cn flag
You can ignore that last entry for the autoloader (`"Drupal\\Driver\\": "../drivers/lib/Drupal/Driver"`) - it's just an optional location that Drupal will look for contributed drivers in. See https://www.drupal.org/node/3123251
cn flag
Reading again, it's not clear from the question what steps you've taken to get to where you're at - under normal conditions, the correct database module (with the driver) will be installed during the site install after you've selected the connection type. Are you doing anything non-typical for your install? Using a non-core profile? Installing via `drush site-install` with some exotic parameters? Anything like that?
Eric MORAND avatar
ru flag
I'm just requiring the core module, creating an entry point index.php that instanciates a custom kernel and that's it. I'm using the framework to create a custom CMS - as I always did up to Drupal 8 - instead of installing a pre-configured site with drush. The documentation of Drupal 9 is very lacking, even more so than Drupal 8 it seems, when it comes to build a CMS instead of configuring a pre built one.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.