简体   繁体   中英

Doctrine can't find the PostgreSQL PDO driver?

I see this question is very similar but I have PDO and pdo_pgsql installed

Here is my error message:

 php app/console doctrine:mapping:convert yml ./src/Vendor/Bundle/MyBundle/Resources/config/doctrine/metadata/orm --from-database --force



  [PDOException]         
  could not find driver  



doctrine:mapping:convert [--filter="..."] [--force] [--from-database] [--extend[="..."]] [--num-spaces[="..."]] [--namespace[="..."]] [--em[="..."]] to-type dest-path 

Here is my config.yml settings

doctrine:
    dbal:
      connections:
        my_database:
          driver:   pdo_pgsql
          port:     5432
          dbname:   blah
          user:     foo
          password: bar
          charset:  UTF8

The host is configured in the prod and dev yaml files like this

doctrine:
    dbal:
      connections:
        my_database:
          host: localhost

running php -m on the command line I see that PDO, pdo_pgsql and pgsql are all installed

PDO
pdo_pgsql
pgsql

What am I missing?

Ugh..

You have to setup the default database first in the parameters.yml file

Well that's what worked for me

In Symfony 2.7 or more the problem is resolved by editing the app/config/config.yml file to leave it to the database which indicates the driver:

doctrine:
    dbal:
        driver: "%database_driver%"

This solution is also useful when multiple databases of different drivers are used, for example, a MySQL database , another PostgreSQL database, ...

First of all, verify your php.ini file: the extensions php_pdo_pgsql and php_pdo must be enabled. Make sure you apply this changes on php.ini file that your symfony project is using (I imagine you are using the tool app/console from symfony), check this on localhost/path_to_your_project/web/config.php . You know if this extensions are enabled executing the function phpinfo().

This command is also helpfull: php -m. It lists on console all the php modules that are loaded.

Tip: check out you Apache error log , there could be something wrong with the load of your extensions. This file is located according to your server configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM