What is Xata?
Laravel

Connect to Postgres with Laravel

Edit on GitHub

To connect your Laravel application to Xata, you need to adjust the database connection in the .env and database.php files as follows:

.env
DB_CONNECTION=pgsql
DB_HOST=<REGION>.sql.xata.sh
DB_PORT=5432
DB_DATABASE=<DATABASE>:<BRANCH>
DB_USERNAME=<WORKSPACE_ID>
DB_PASSWORD=<API_KEY>
DB_SSLMODE=require

Please replace the parameters as indicated on the connect to Postgres page.

app/config/database.php
'pgsql' => [
    'driver' => 'pgsql',
    'url' => env('DATABASE_URL'),
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '5432'),
    'database' => env('DB_DATABASE', 'forge'),
    'username' => env('DB_USERNAME', 'forge'),
    'password' => env('DB_PASSWORD', ''),
    'charset' => 'utf8',
    'prefix' => env('DB_PREFIX', ''),
    'prefix_indexes' => true,
    'search_path' => 'public',
    'sslmode' => 'require', // 1.
],
  1. Optional to set the sslmode as Xata mandates require as minimum, see sslmodes for more information.