Error connecting a postegresql database to Laravel

0

I'm having a problem when using Laravel with postgresql on Linux, when trying to connect to the database it says that I do not find the postgresql driver, I already enabled postgresql in php.ini like this:

extension=pgsql.so
extension=pdo_pgsql.so

This is the SQL Query:

$usuario = DB::select('select * from usuario');

The error that Laravel shows me is this:

"could not find driver (SQL: select * from usuario)"

I have already installed the php-postgresql driver, I have already restarted the two apache2 services, postgresql and also restarted the composer.

My distro is elementaryOS (based on ubuntu 14.04)

edit: .env:

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=minha_db
DB_USERNAME=meu_user 
DB_PASSWORD=minha_senh3

database.php

'pgsql' => [
    'driver' => 'pgsql',
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '5432'),
    'database' => env('DB_DATABASE', 'minha_db'),
    'username' => env('DB_USERNAME', 'meu_user'),
    'password' => env('DB_PASSWORD', 'minha_senha'),
    'charset' => 'utf8',
    'prefix' => '',
    'schema' => 'public',
    'sslmode' => 'prefer',
],

Edit: Thanks God I was able to solve it, I tried to install the package with the command below and the driver worked:

sudo apt-get install php7.0-pgsql

Before I had installed without specifying the version and it did not work:

sudo apt-get install php-pgsql
    
asked by anonymous 09.10.2017 / 05:41

0 answers