PHP Startup : Unable to load dynamic library PGSQL

Viewed 40727

I'am trying to run Symfony 3.x with :

  • Ubuntu 16.04
  • PHP 7.0
  • NGinx

I would like to interact with my PGSQL database that I created but I get this error :

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_pdo_pgsql.dll' - /usr/lib/php/20151012/php_pdo_pgsql.dll: cannot open shared object file: No such file or directory in Unknown on line 0

[Doctrine\DBAL\Exception\DriverException] An exception occured in driver: could not find driver
[Doctrine\DBAL\Driver\PDOException] could not find driver

[PDOException] could not find driver

So I looked at my phpinfo() and it seems that pgsql driver is enabled

phpinfo() result

Can anyone help me on this one ?

4 Answers

I had a very similar issue:

I fixed it by applying the same patch as for this subject: pdo_parse_params error in pdo_odbc.so whenever PHP starts in Fedora 20

In a nutshell: if a module has already been loaded by the /etc/php/7.2/mods-available/<module>.ini (or equivalent path for your OS), then the module should not be uncommented (= made active) in the php.ini files. (two of them, cli and server).

You may ensure this, by checking phpinfo(), and observe how pdo_pgsql is still active in there, despite the line being commented in php.ini!

For me, none of the above solutions worked. Uncommenting extension=pgsql in php.ini also didn't work in and of itself.

It seemed as if postgresql wasn't installed even though I had installed it on my Ubuntu using

sudo apt-get install postgresql-12 

Finally, I realized I had to install:

sudo apt-get install php-pgsql

I had a similar problem and (after installing the PHP pg driver) I had to add two files to /etc/php.d

20-pgsql.ini

extension=pgsql.so

30-pdo-pgsql.ini

extension=pdo_pgsql.so

Putting these extension config lines in the php.ini kept giving me the pdo_parse_params error

Related