> ## Documentation Index
> Fetch the complete documentation index at: https://darkterminal.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration

> Configure the database connection

LibSQL has 4 types of connections to interact with the database: **In-Memory Connection**, **Local Connection**, **Remote Connection**, and **Remote Replica Connection (Embedded Replica)**.

## In-Memory Connection

```php theme={null}
$params = [
    "url"               => ":memory:",
    'driverClass'       => \Darkterminal\LibSQL\DBAL\Driver::class,
];
```

## Local Connection

```php theme={null}
$params = [
    "url"               => "database.db",
    'driverClass'       => \Darkterminal\LibSQL\DBAL\Driver::class,
];
```

If you want to create Remote Connection or Remote Replica (Embedded Replica) Connection, you will need an existing database to continue. If you don’t have one, **[create one](https://docs.turso.tech/quickstart)**.

Get the database URL:

```shell theme={null}
turso db show --url <database-name>
```

Get the database authentication token:

```shell theme={null}
turso db tokens create <database-name>
```

If you use `.env` file, assign credentials to the environment variables inside `.env`.

```env theme={null}
TURSO_DATABASE_URL=
TURSO_AUTH_TOKEN=
```

## Remote Connection

```php theme={null}
$params = [
    "auth_token"        => "<your-database-auth-token-from-turso>",
    "sync_url"          => "<your-database-url-from-turso>",
    'driverClass'       => \Darkterminal\LibSQL\DBAL\Driver::class,
];
```

## Remote Replica (Embedded Replica) Connection

```php theme={null}
$params = [
    "url"               => "database.db",
    "auth_token"        => "<your-database-auth-token-from-turso>",
    "sync_url"          => "<your-database-url-from-turso>",
    "sync_interval"     => 5,    // Optional, default is: 5 in seconds
    "read_your_writes"  => true, // Optional, default is: true
    "encryption_key"    => "",   // Optional, default is: empty
    'driverClass'       => \Darkterminal\LibSQL\DBAL\Driver::class,
];
```
