1

I'm getting the "Driver not found" PDO exception when trying to connect to PostgreSQL DB and I can't seem to figure out what's happening. Here are system specs:

WampServer Version 3.0.3 64bit
PHP 7.1.10
Apache 2.4.9
Laravel 5.5

I downloaded PosgtreSQL 10 (Windows x86-64) from here - EnterpriseDB

Here are all the relevant screenshots:

Error

Database Config

PHP Extensions

PHP Info

PG Admin

Environment Variables

extension_loaded('pgsql')

returns true

The only discrepancy that I see is that I downloaded PostgreSQL 10, and PHP Info says PostgreSQL(libpq) Version is 9.6.2. Could that be an issue?

EDIT:

I replaced PostgreSQL 10 with 9.6.5 (which is the only available 9.6 version), and it didn't fix the issue.

EDIT 2:

$dbh = new PDO("pgsql:dbname=laravel_admin_api;host=127.0.0.1", "postgres", "admin");
echo $dbh ? "connected" : "failed";

returns connected. So it's gotta be a Laravel issue?

EDIT 3:

Ok, so the connection to the database works, I created a table and inserted a row manually through pgAdmin, and then called

\App\User::all()->toArray()

and that worked. So it's actually php artisan migrate that's having issues, and throwing the could not find driver exception. Still stumped on that one.

GTCrais
  • 2,039
  • 2
  • 26
  • 32
  • What does your migration look like? – kerrin Nov 08 '17 at 21:48
  • Default 2 migrations that ship with Laravel (users and migrations tables). There are no problems when I switch to mysql or sqlite. – GTCrais Nov 08 '17 at 22:05
  • Couple of points: Latest version of WampServer is 3.1.0 and it is better to install WAMPServer into the root of a drive, and not into `Program Files` – RiggsFolly Nov 09 '17 at 00:42

1 Answers1

0

I was facing the same issue and I tried couple of solutions through the internet. None of those worked for me and finally I could get it to work by installing Apache 2.4 and php 7.2.7 separately instead of using Xamp or Wamp on windows. Sharing most important steps so that it might be helpful for anyone out there.

  1. Install Apache as per https://www.sitepoint.com/how-to-install-apache-on-windows/. In my case I installed Apache 2.4
  2. Install PHP as an Apache module - https://www.sitepoint.com/how-to-install-php-on-windows/ (I downloaded PHP thread safe version for Windows 64)

If you get both of above to work properly. Install Laravel in the htdocs and try php artisan migrate command.

DSEJ
  • 131
  • 4