Victor Alfonso's avatar

PDOException::("could not find driver") - Laravel 8 connection to postgresql

Hi i got some problems to get connection to my db instance in postgres, i running laravel 8 on windows 10 "wamp" and installed postgresql. I start up all the services of the pgsql with pgAdmin4 and in wamp server i activated all pgsql extensions as well, and alway i get this error on the moment to run the migration for the db

 Illuminate\Database\QueryException 

  could not find driver (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations and table_type = 'BASE TABLE') 

  at C:\wamp64\www\dc\APRAY-50\client-dashboard\vendor\laravel\framework\src\Illuminate\Database\Connection.php:678
    674▕         // If an exception occurs when attempting to run a query, we'll format the error
    675▕         // message to include the bindings with SQL, which will make this exception a
    676▕         // lot more helpful to the developer instead of just the database's errors.
    677▕         catch (Exception $e) {
  ➜ 678▕             throw new QueryException(
    679▕                 $query, $this->prepareBindings($bindings), $e
    680▕             );
    681▕         }
    682▕

  1   C:\wamp64\www\dc\APRAY-50\client-dashboard\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDOException::("could not find driver")

  2   C:\wamp64\www\dc\APRAY-50\client-dashboard\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDO::__construct("pgsql:host=localhost;dbname=apray-1;port=5432;sslmode=prefer", "postgres", "root", [])

this is my .env config

DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=apray-1
DB_USERNAME=postgres
DB_PASSWORD=root

I also tried to clean config cache but still no working

0 likes
5 replies
jlrdw's avatar
jlrdw
Best Answer
Level 75

Are you sure it's enabled in php.ini. or if enabled while server was running, restart the server.

jlrdw's avatar

Can you connect outside of laravel and if so have you created the users table.

Victor Alfonso's avatar

The solution to this problem is simply in my case go to the wamp control panel and from there click on the php.ini file of the php version you are using, and inside it activate the pgsql module, if it is not activated by this method you can go directly to the bin folder where the php of the version you are using is installed and there make the modification to activate the module in question.

jlrdw's avatar

That's what I said in my first reply to enable it in your PHP.ini file. But good you got it working.

Please or to participate in this conversation.