Improve driver error message#7063
Conversation
|
I fail to understand how the proposed change would've helped uncover that the PDO extension was missing. |
|
I upvoted the description then felt something similar when seeing the diff. |
|
My intention was to make the error message more explicit about which component encountered an issue, to help users quickly narrow down the area to investigate. I agree that this change alone does not directly indicate a missing PDO extension, but it may help users distinguish between different types of drivers in larger applications. |
|
I'd like to propose an enhancement also for the connection logic to provide immediate and actionable feedback when a required PHP extension for the database driver is missing. if (!extension_loaded($params['driver'])) {
throw Exception::driverNotInstalled($params['driver']);
}Exception.php: public static function driverNotInstalled(string $driverName): self
{
return new self(sprintf('Please install the "%s" PHP extension.', $driverName, PHP_EOL));
} |
Your intention is good, but the proposed change does not achieve your goal. I'm sorry, but I'm going to close this PR. If you find a better way, please open a new PR. |
Summary
While working on a Symfony 7.4 project using PHP 8.3, I encountered the following error when trying to run database migrations on a PostgreSQL database:
At first, the message was unclear and didn't indicate the root cause. It also didn't reference PostgreSQL or the database layer explicitly, which made it harder to debug. After further investigation, I discovered that the
pdo_pgsqlextension was not installed for PHP 8.3.To improve clarity and developer experience, I updated the exception.
This wording makes it clearer that the issue is related to the database driver and may help developers diagnose the problem more quickly.