Skip to content

Configuration

Imam Ali Mustofa edited this page Nov 10, 2026 · 1 revision

Configuration

All driver-specific configuration goes in .env (and the connections block of config/database.php).

Laravel core variables

DB_CONNECTION=libsql
DB_DATABASE=database.sqlite   # or :memory:

LibSQL driver variables

DB_AUTH_TOKEN=<your-database-auth-token-from-turso>
DB_SYNC_URL=<your-database-url-from-turso>
DB_SYNC_INTERVAL=5
DB_READ_YOUR_WRITES=true
DB_ENCRYPTION_KEY=<your-encryption-key>
DB_SQLD_OFFLINE_MODE=false
DB_OFFLINE_WRITES=false
Variable Meaning Default Verified
DB_AUTH_TOKEN Turso Cloud database token empty remote/remote-replica tests
DB_SYNC_URL URL of the remote database empty remote/replica tests
DB_SYNC_INTERVAL Replica sync interval in seconds 5 embedded replica tests
DB_READ_YOUR_WRITES Writes visible to subsequent reads in the same connection true embedded replica tests
DB_ENCRYPTION_KEY Encrypts the database at rest (positional encryption_key argument, effective at creation time) empty docker proof phase encryption
DB_SQLD_OFFLINE_MODE Enable sqld offline-write flavor false docker proof phases + MultiConnectionTest
DB_OFFLINE_WRITES Enable offline-write flavor (paired with the above for sqld; alone for Turso Cloud) false LocalRemoteReplicaTest + TursoCloudOfflineWriteTest

config/database.php

Add this block to the connections array:

'libsql' => [
    'driver' => 'libsql',
    'database' => env('DB_DATABASE', database_path('database.sqlite')),
    'prefix' => '',
    'url' => env('DB_SYNC_URL', ''),
    'authToken' => env('DB_AUTH_TOKEN', ''),
    'syncInterval' => env('DB_SYNC_INTERVAL', 5),
    'read_your_writes' => env('DB_READ_YOUR_WRITES', true),
    'encryptionKey' => env('DB_ENCRYPTION_KEY', ''),
    'sqldOfflineMode' => env('DB_SQLD_OFFLINE_MODE', false),
    'offlineWrites' => env('DB_OFFLINE_WRITES', false),
],

Copy the block as-is; arbitrary values may break the connection.

Multiple libsql connections

Every statically configured driver: libsql connection is extended by name individually (since 1.6.0) with its own raw configuration — connections no longer silently reuse the default's settings. Covered by tests/Feature/MultiConnectionTest.php in CI.

Clone this wiki locally