Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PGSQL driver not found in Laravel PHP Framework

Hi I am using Laravel PHP framework on CentOS 6.3. I have PostgreSQL 9.1 installed, along with PDO and PDO-PGSQL. Under application/config/database.php I have set Laravel to use PostgreSQL:

'default' => 'pgsql',


'connections' => array(

    'pgsql' => array(
        'driver'   => 'pgsql',
        'host'     => 'localhost',
        'database' => 'dbname',
        'username' => 'username',
        'password' => 'shhhpass',
        'charset'  => 'utf8',
        'prefix'   => '',
        'schema'   => 'public',
    ),
),

However, visiting any page gives me the error:

Message:

could not find driver
Location:     

/home/dev/public_html/laravel/database/connectors/postgres.php on line 37

Any ideas? Thanks!

like image 920
Nyxynyx Avatar asked Dec 16 '22 19:12

Nyxynyx


2 Answers

Run sudo apt-get install php5-pgsql on your terminal.

In other words, install the PostgreSQL driver for PHP.

like image 72
Koen Schmeets Avatar answered Dec 18 '22 08:12

Koen Schmeets


The line giving that error is this:

$connection = new PDO($dsn, $username, $password, $this->options($config));

It is trying to load the PDO driver for pg.

Did you check that the pdo extension is enabled in PHP configuration files? Check the /etc/php.d/pgsql.ini and /etc/php.d/pdo.ini.

Hope this helps.

like image 28
Omid Kamangar Avatar answered Dec 18 '22 08:12

Omid Kamangar