1

I'm trying to connect to the PostgreSQL database through laravel in order to make a php artisan migrate , but I get the error

[PDOException] could not find driver

looking at similar questions found there to enable extensions in php.ini but did not solve my problem, still gives me the same error.

In other parts of my code I use the database and I can add records so I think my settings database right. I do not understand the error.

Database.php file:

<?php return [ 
      'fetch' => PDO::FETCH_CLASS, 
      'default' => env('DB_CONNECTION', 'pgsql'), 
      'connections' => [ 
             'pgsql' => [ 
                  'driver' => 'pgsql', 
                  'host' => env('DB_HOST', 'localhost'), 
                  'database' => env('DB_DATABASE', 'forge'), 
                  'username' => env('DB_USERNAME', 'forge'), 
                  'password' => env('DB_PASSWORD', ''), 
                  'charset' => 'utf8', 'prefix' => '', 
                  'schema' => 'public', 
              ], 
        ], 
        'migrations' => 'migrations', 
  ]; ?>
Raj Kamal
  • 577
  • 6
  • 15
Steph27
  • 31
  • 4
  • can you please post your `database.php` file ?? – Drudge Rajen Apr 09 '16 at 16:33
  • PDO::FETCH_CLASS, 'default' => env('DB_CONNECTION', 'pgsql'), 'connections' => [ 'pgsql' => [ 'driver' => 'pgsql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public', ], ], 'migrations' => 'migrations', ]; – Steph27 Apr 09 '16 at 16:43
  • My usual checks when deploying: make sure storage folder is writable by the user. Env file has correct details. Run command composer dump-autoload – Cloud_Ratha Apr 09 '16 at 17:04
  • Sometimes the env in server goes one lined , so check and break the single line , it caused me issues most of the times –  Apr 11 '16 at 05:57

1 Answers1

0

Check if you have pdo_pgsql extention.

You can

php -i | grep pgsql

to see it.

XiaoChi
  • 369
  • 4
  • 4