Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL

I'm trying to connect with PostgreSQL database through Laravel in order to do a php artisan migrate but doesn't seem to be directed since it's reading the database name of MySQL.

Here are the commands from database.php:

'connections' => array(      'sqlite' => array(         'driver'   => 'sqlite',         'database' => __DIR__.'/../database/production.sqlite',         'prefix'   => '',     ),      'mysql' => array(         'driver'    => 'mysql',         'host'      => 'localhost',         'database'  => 'database',         'username'  => 'root',         'password'  => '',         'charset'   => 'utf8',         'collation' => 'utf8_unicode_ci',         'prefix'    => '',     ),      'pgsql' => array(         'driver'   => 'pgsql',         'host'     => 'localhost',         'database' => 'postgres',         'username' => 'postgres',         'password' => 'root',         'charset'  => 'utf8',         'prefix'   => '',         'schema'   => 'public',     ),      'sqlsrv' => array(         'driver'   => 'sqlsrv',         'host'     => 'localhost',         'database' => 'database',         'username' => 'root',         'password' => '',         'prefix'   => '',     ),  ), 

If I remove the MySQL paths I'll get:

[InvalidArgumentException] Database [mysql] not configured. 


EDIT: When trying to do php artisan migrate I get a 'PDOException: could not find driver'. I'm using WAMP and I'm in Win8.1. Using PostgreSQL as database.


EDIT: Have experimented a series of alternative solutions but I'm still ought to get this solved. The php.ini file was checked in Apache, WAMP (from php folder) and PostgreSQL. The extension_dir is correct as it being -> extension_dir = "c:/wamp/bin/php/php5.5.12/ext/"

The extension=pdo_pgsql.dll and extension=pgsql.dll are uncommented.

Done the PATH trick in the 'System Variables' and rebooted. No chance.

Thanks for the help so far.

These are my drivers php_pdo_driver.h & php_pdo.h from C:\Program Files (x86)\PostgreSQL\EnterpriseDB-ApachePHP\php\SDK\include\ext\pdo

Information from phpinfo:

PHP Version 5.5.12

Compiler MSVC11 (Visual C++ 2012) Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-sdk\oracle\x64\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\x64\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\x64\instantclient11\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo"

like image 756
Hyperion Avatar asked Aug 15 '14 15:08

Hyperion


1 Answers

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:

  • http://php.net/manual/en/install.pecl.windows.php
  • http://webcheatsheet.com/php/install_and_configure.php#extsetup
like image 81
lainceline Avatar answered Sep 22 '22 11:09

lainceline