简体   繁体   中英

creating database from postgreSQL with symfony

I am working with mapbender3 which is developed in symfony2 on my local machine. I am asked to connect the application to a remote potgreSQL server. Following is the configuration in the parameters.yml file.

parameters:
    database_driver:   pdo_pgsql
    database_host:     192.168.3.100
    database_port:     5434
    database_name:     idc_core
    database_path:     ~
    database_user:     *******
    database_password: *******

    mailer_transport:  smtp
    mailer_host:       localhost
    mailer_user:       ~
    mailer_password:   ~

But when I run the command:

php app/console doctrine:database:create

I keep getting the below error

could not create database for connection named "idc_core"
cound not find driver

I am using WAMP server on windows 7 and the driver pdo_pgsql shows active and running on my local computer.

I have checked phpinfo() and it displayed pdo_pgsql as enabled but when I run php -m in commandline to see the modules compiled in,

I can see PDO , pdo_mysql and pdo_sqlite but not pdo_pgsql

Be sure to configure the 'default' key in app/config/database.php

For postgres, this would be 'default' => 'postgres',

If you are receiving a [PDOException] could not find driver error, check to see if you have the correct PHP extensions installed. You need pdo_pgsql.so and pgsql.so installed and enabled. Instructions on how to do this vary between operating systems.

For Windows, the pgsql extensions should come pre-downloaded with the official PHP distribution. Just edit your php.ini and uncomment the lines extension=pdo_pgsql.so and extension=pgsql.so

Also, in php.ini , make sure extension_dir is set to the proper directory. It should be a folder called extensions or ext or similar inside your PHP install directory.

Finally, copy libpq.dll from C:\\wamp\\bin\\php\\php5.*\\ into C:\\wamp\\bin\\apache*\\bin and restart all services through the WampServer interface.

If you still get the exception, you may need to add the postgres \\bin directory to your PATH :

  1. System Properties -> Advanced tab -> Environment Variables
  2. In 'System variables' group on lower half of window, scroll through and find the PATH entry.
  3. Select it and click Edit
  4. At the end of the existing entry, put the full path to your postgres bin directory. The bin folder should be located in the root of your postgres installation directory.
  5. Restart any open command prompts, or to be certain, restart your computer.

This should hopefully resolve any problems. For more information see:

Source: https://stackoverflow.com/a/25336292/1045444

You should add pdo_pgsql extension into the CLI config of your php in

yourPhpDirectory/cli/php.ini

CLI uses this config to work in command line, not the one for apache. This is the reason why phpinfo(); shows you pdo_pgsql and php -m not. Also under Windows OS you should restart your command line tool to see differences after any config changes.

  1. Enable both extensions php_pdo_pgsql and php_pgsql in php.ini (the one for the CLI):

     extension=php_pdo_pgsql.dll extension=php_pgsql.dll 
  2. Ensure that "Port" and "Login Credentials" for the remote server are correct by testing from a database administration tool, like Adminer.

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