0

I am setting up my Symfony 3 project (using Netbeans IDE) and want to use PostgreSQL as my database instead of MySQL. After some time online I have found a few potential solutions (one of which is mentioned here but this one does not seem to work for me). So:

  1. My symfony 3 project is running on the local MAMP server
  2. PostgreSQL server is running on the local machine as well
  3. I have setup my parameters.yml file as per below:
- database_driver: pdo_pgsql
- database_host: localhost
- database_port: 5432
- database_name: mypgdatabase
- database_user: mypguser
- database_password:  mypguserpass

The error that i am getting when generating entities is:

  [Doctrine\DBAL\Exception\DriverException]              

  An exception occurred in driver: could not find driver

  [Doctrine\DBAL\Driver\PDOException]  

  could not find driver

  [PDOException]             could not find driver

Been trying to figure this one out for a few days now so any help will he highly appreciated.

chadyred
  • 424
  • 1
  • 9
  • 19
Sky21.86
  • 627
  • 2
  • 9
  • 26

2 Answers2

1

Have you checked in your "php.ini" file that you have this:

extension=pdo.so
extension=php_pdo_pgsql.so

The php.ini file location might depend on which operating system you are using, if it's a mac run:

$ locate php.ini
Alvin Bunk
  • 7,621
  • 3
  • 29
  • 45
  • Thanks Alvin Bunk, i am using mama server on OS X and non of the above is in my php.ini file. Next question is who do i get those extantions installed. the one that i do have tho is ;extension=php_pdo_pgsql.dll however it is commented out and extension=pdo.so is missing as such. – Sky21.86 Jun 16 '16 at 17:55
  • Try uncommenting `;extension=php_pdo_pgsql.dll` (remove the semicolon) and see what happens. You might need to restart Apache. – Alvin Bunk Jun 16 '16 at 18:07
  • uncommented and restarted MAMP, getting these errors now: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20121212/php_pdo_pgsql.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/php_pdo_pgsql.dll, 9): image not found in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20121212/php_pgsql.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/php_pgsql.dll, 9): image not found in Unknown on line 0 – Sky21.86 Jun 16 '16 at 18:27
  • You might have to install PostgreSQL support for PHP. Take a look at [this question](http://stackoverflow.com/questions/6588174/enabling-postgresql-support-in-php-on-mac-os-x) and the answer in particular. My original answer is correct though, and you should mark it as the correct answer. You need to figure out how to enable the `php_pdo_pgsql.so` module. – Alvin Bunk Jun 16 '16 at 20:21
1

This is an easy way to check for PHP modules

php -m | grep 'pdo\|pgsql'

It looks like you need both PDO_pgsql and pgsql

user2182349
  • 9,569
  • 3
  • 29
  • 41