Updated June 2026. Tested on Laravel 13 and PHP 8.4.

PostgreSQL is a strong choice for a Laravel app, and Laravel supports it as a first class driver. Connecting to it follows the same pattern as MySQL, with one extension to enable and a couple of Postgres specific options.

Enable the PDO extension

Laravel reaches PostgreSQL through PHP's pdo_pgsql extension. Install it and confirm it is loaded.

sudo apt install php8.4-pgsql
php -m | grep pdo_pgsql

If it is missing, you get "could not find driver", which is the usual first stumble.

Set the .env

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=techalyst
DB_USERNAME=techalyst
DB_PASSWORD=secret

PostgreSQL listens on port 5432 by default.

The connection in config/database.php

Laravel ships with a pgsql connection ready to go.

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

Two options are worth knowing. search_path (older versions called it schema) sets which Postgres schema your tables live in, and defaults to public. sslmode controls TLS; prefer is fine locally, while a managed Postgres in production usually wants require.

Test it

php artisan migrate

If the extension is loaded and the credentials are right, your tables are created in Postgres. Questions welcome in the comments.