Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kickthemooon's avatar

Wamp / Laravel 5.3 / Postgres pdo exception could not find driver

I am having a hard time setting up laravel 5.3 (running on wamp/windows) with pgsql. I am getting an error "PDO Exception - Could not find driver" when I am trying to migrate tables with "php artisan migrate"

  1. I installed postgres 9.6.
  2. I enabled the php extensions for postgresql:

pg-path-variable

  1. I added postgres libraries to environment path variable

php-info-pgsql

  1. I tested the pdo postgres connection with php and I am getting connected:
$dbh = new PDO("pgsql:dbname=rotocms;host=127.0.0.1", "postgres", "mypassword");

if($dbh) {
   echo 'connected';
} else {
    echo 'there has been an error connecting';
} 

So I am stuck, cant get the migration to work in laravel. My .env:

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=mydatabasename
DB_USERNAME=postgres
DB_PASSWORD=password

Here is the laravel error stack trace:

local.ERROR: PDOException: could not find driver in C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:119
Stack trace:
#0 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php(119): PDO->__construct('pgsql:host=127....', 'postgres', 'password', Array)
#1 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php(56): Illuminate\Database\Connectors\Connector->createPdoConnection('pgsql:host=127....', 'postgres', 'password', Array)
#2 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Connectors\PostgresConnector.php(36): Illuminate\Database\Connectors\Connector->createConnection('pgsql:host=127....', Array, Array)
#3 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Connectors\ConnectionFactory.php(100): Illuminate\Database\Connectors\PostgresConnector->connect(Array)
#4 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors{closure}()
#5 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Connection.php(964): call_user_func(Object(Closure))
#6 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Connection.php(832): Illuminate\Database\Connection->getPdo()
#7 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Connection.php(717): Illuminate\Database\Connection->reconnectIfMissingConnection()
#8 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Connection.php(350): Illuminate\Database\Connection->run('select * from i...', Array, Object(Closure))
#9 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Schema\PostgresBuilder.php(25): Illuminate\Database\Connection->select('select * from i...', Array)
#10 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Migrations\DatabaseMigrationRepository.php(156): Illuminate\Database\Schema\PostgresBuilder->hasTable('migrations')
#11 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php(515): Illuminate\Database\Migrations\DatabaseMigrationRepository->repositoryExists()
#12 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Console\Migrations\MigrateCommand.php(92): Illuminate\Database\Migrations\Migrator->repositoryExists()
#13 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Database\Console\Migrations\MigrateCommand.php(58): Illuminate\Database\Console\Migrations\MigrateCommand->prepareDatabase()
#14 [internal function]: Illuminate\Database\Console\Migrations\MigrateCommand->fire()
#15 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Container\Container.php(508): call_user_func_array(Array, Array)
#16 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Console\Command.php(169): Illuminate\Container\Container->call(Array)
#17 C:\wamp64\www\myproject\vendor\symfony\console\Command\Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Console\Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 C:\wamp64\www\myproject\vendor\symfony\console\Application.php(820): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 C:\wamp64\www\myproject\vendor\symfony\console\Application.php(187): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 C:\wamp64\www\myproject\vendor\symfony\console\Application.php(118): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(121): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 C:\wamp64\www\myproject\artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 {main}  

Any suggestions are welcome

0 likes
6 replies
JhumanJ's avatar

I have the exact same probem with Mamp...

kickthemooon's avatar

@JhumanJ not sure how or what i did, but after hours it started to work finally. I think the thing that got it to work is the php path in my windows path variable. I think it was not right. Now i dont know if mac has something like this path variable.

princelionelnzi's avatar

After activating the following extensions by using the wamp icon in the taskbar: -php_pdo_pgsql.dll -php_pgsql.dll

The solution is to uncomment the extensions in the following files:

~/wamp/bin/php/php5.5./php.ini ~/wamp/bin/php/php5.5./phpForApache ~/wamp/bin/php/php5.5./php.ini.install ~/wamp/bin/php/php5.5./php.ini-development ~/wamp/bin/php/php5.5.*/php.ini-production and ~/wamp/bin/apache/apache2.4.9/php.ini

** You can leave off the "php.ini-development" and "php.ini-production" (don't need to uncoment these files).

Hope it helps

1 like
hdifen's avatar

Posting here for other people who might have the same problem. I had a similar issue, I had previously installed php before I had installed xampp so my system variable was pointing to the wrong place which in turn made my php.ini file in xampp not get used.

Please or to participate in this conversation.