0

I start my Symfony application named "test2" using the terminal command symfony serve (I also tried symfony 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 ran sudo apt-get install php-pgsql.

I checked "php.ini" as well, here's a screenshot: enter image description here

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 :)

13
  • did you check your php.ini to see if the extension=pdo_pgsql is uncommented Commented May 30, 2021 at 21:44
  • Yes, pretty sure it's uncommented. I just added a screenshot of "php.ini". Thanks for asking. Commented May 30, 2021 at 21:54
  • It is not in use in the above screenshot, remove the leading ; from that line and restart you webserver and/or php-fpm Commented May 30, 2021 at 21:56
  • try to remove the semi colon at the begining and se if it work Commented May 30, 2021 at 21:58
  • Tried it, then restarted "sudo service apache2 restart", but unfortunately, still the same problem :( Commented May 30, 2021 at 22:29

2 Answers 2

1

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 with ls -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 or sudo 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 entered sudo 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 :)

Sign up to request clarification or add additional context in comments.

Comments

0

You probably need to remove the semicolon from that line and then restart your webserver.

Usually something like sudo service httpd restart.

2 Comments

I tried it, did "sudo service apache2 restart" (tried "httpd" as well, but said it didn't exist), and I still have the same problem :(
Do you know what web server you are running / os?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.