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

Posted 2 years ago by kickthemooon

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

Please sign in or create an account to participate in this conversation.