Error trying to migrate bd from Laravel to PostgreSQL

2

I'm using PostgreSQL "5.4. *"

Using MySQL, after php artisan migrate ok.

But now I need to use PostgreSQL in the project, but after changing the DB:

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=laravel-api
DB_USERNAME=postgres
DB_PASSWORD=1234

Give me this error:

D:\wamp64\www\laravel\laravel-api>php artisan migrate

  [Illuminate\Database\QueryException]
  could not find driver (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations)


  [PDOException]
  could not find driver

Detail, the environment is Windows.

    
asked by anonymous 17.10.2017 / 20:25

1 answer

2

To enable PDO extension for postgres in PHP, the first step is to find the following line in php.ini and remove ;

;extension=php_pdo_pgsql.dll

Then restart apache. You can verify that the installation occurred correctly with phpinfo() , should show something like:

AnotherwaytoseewhichPDOdriversareinstalledistocallthestaticmethod PDO::getAvailableDrivers()

<?php
echo "<pre>";
print_r(PDO::getAvailableDrivers());

Output:

Array
(
    [0] => mysql
    [1] => pgsql
    [2] => sqlite
)
    
17.10.2017 / 20:34