postgresql - PHP Symfony server - "An exception occurred in driver: could not find driver"
Get the solution ↓↓↓I start my Symfony application named "test2" using the terminal commandsymfony serve
(I also triedsymfony server:start
), and I get an error:
Exception thrown when handling an exception (Doctrine\DBAL\Exception\DriverException: An exception occurred in driver: could not find driver at /var/www/html/test2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php line 102)
I'm using Ubuntu 20.04, PHP 7.4, Symfony CLI 4.25, and in case needed, Composer 2.0
I'm also using PostgreSQL, and I ransudo apt-get install php-pgsql
.
I checked "php.ini" as well, here's a screenshot:
This is the entire response that highlights the error(s):
[Web Server ] May 31 09:01:32 |DEBUG | PHP Using PHP version 7.4.18 (from default version in $PATH)
[Application] May 30 23:09:16 |CRITICA| REQUES Exception thrown when handling an exception (Doctrine\DBAL\Exception\DriverException: An exception occurred in driver: could not find driver at /var/www/html/test2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php line 102)
[Application] May 30 23:09:16 |CRITICA| PHP Uncaught Exception: An exception occurred in driver: could not find driver
[Application] May 30 23:16:58 |INFO | REQUES Matched route "index". method="GET" request_uri="https://localhost:8000/" route="index" route_parameters={"_controller":"App\\Controller\\TestController::index","_route":"index"}
[Application] May 30 23:16:58 |INFO | SECURI Populated the TokenStorage with an anonymous Token.
[Application] May 30 23:16:58 |CRITICA| REQUES Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: "An exception occurred in driver: could not find driver" at /var/www/html/test2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php line 102
[Application] May 30 23:16:58 |CRITICA| REQUES Exception thrown when handling an exception (Doctrine\DBAL\Exception\DriverException: An exception occurred in driver: could not find driver at /var/www/html/test2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php line 102)
[Application] May 30 23:16:58 |CRITICA| PHP Uncaught Exception: An exception occurred in driver: could not find driver
[Application] May 30 23:16:58 |CRITICA| REQUES Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: "An exception occurred in driver: could not find driver" at /var/www/html/test2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php line 102
[Application] May 30 23:16:58 |CRITICA| REQUES Exception thrown when handling an exception (Doctrine\DBAL\Exception\DriverException: An exception occurred in driver: could not find driver at /var/www/html/test2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php line 102)
[Application] May 30 23:16:58 |CRITICA| PHP Uncaught Exception: An exception occurred in driver: could not find driver
[Web Server ] May 31 09:01:32 |INFO | PHP listening path="/usr/sbin/php-fpm7.4" php="7.4.18" port=45197
[PHP-FPM ] May 31 09:01:32 |NOTICE | FPM fpm is running, pid 391
[PHP-FPM ] May 31 09:01:32 |NOTICE | FPM ready to handle connections
[PHP-FPM ] May 31 09:01:32 |NOTICE | FPM systemd monitor interval set to 10000ms
Does anyone have an idea?
Thanks in advance to any helpers :)
Answer
Solution:
You probably need to remove the semicolon from that line and then restart your webserver.
Usually something likesudo service httpd restart
.
Answer
Solution:
Problem solved! I removed and reinstalled PHP's PostgreSQL extension, anything linked to Symfony, and permanently removed unused PHP versions. I also surprisingly left the comments in "php.ini", didn't need to touch it. It now works.
Here's a link that explains how to remove Symfony (look at the 2nd answer withls -al ~/.symfony
, etc.): How to completely uninstall symfony and composer from a mac
To remove PHP's PostgreSQL extension:sudo apt-get --purge remove php-pgsql
orsudo apt-get purge php-pgsql
And I removed unused PHP versions on my system:sudo apt-get purge 'php5.6'
To reinstall PHP's PostgreSQL extension, I enteredsudo apt-get install php-pgsql
And to get Symfony again, I followed its steps here: https://symfony.com/download (for Linux)
Thanks to everyone who offered their help. I greatly appreciate it :)
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.