5

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!

2 Answers 2

7

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

In other words, install the PostgreSQL driver for PHP.

Sign up to request clarification or add additional context in comments.

1 Comment

The OP stated that he is using CentOS. These instructions are for Debian/Ubuntu.
6

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.

1 Comment

Note: After installing the PDO driver one needs to restart Apache for the changes to be effected: sudo systemctl restart httpd.service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.