PHPackages                             tursodatabase/turso-driver-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. tursodatabase/turso-driver-laravel

ActiveLibrary[Database &amp; ORM](/categories/database)

tursodatabase/turso-driver-laravel
==================================

A Turso Driver for Laravel

1.3.1(11mo ago)975.8k↓37.2%11[3 PRs](https://github.com/tursodatabase/turso-driver-laravel/pulls)MITPHPPHP ^8.2CI passing

Since Jun 6Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/tursodatabase/turso-driver-laravel)[ Packagist](https://packagist.org/packages/tursodatabase/turso-driver-laravel)[ Docs](https://github.com/tursodatabase/turso-driver-laravel)[ GitHub Sponsors](https://github.com/darkterminal)[ RSS](/packages/tursodatabase-turso-driver-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (9)Versions (33)Used By (0)

Caution

There is a new adapter coming soon for Laravel that doesn't require using an extension. This extension doesn't support offline writes beta. Join us on Discord to talk more -

 [    ![Shows a black logo in light color mode and a white one in dark color mode.](https://camo.githubusercontent.com/1231973ca7d74462fee93f4c961bcd721ad05606533ba80fa84994344a26ba78/68747470733a2f2f692e696d6775722e636f6d2f764743433049342e706e67)  ](https://discord.gg/turso)

 [![Turso + Laravel](https://camo.githubusercontent.com/cf19e28e4351bf3bc26e392ac3265cdec2deb82698d59b580e9cded3a6e9b1e2/68747470733a2f2f692e696d6775722e636f6d2f64706d6c36594b2e706e67)](https://camo.githubusercontent.com/cf19e28e4351bf3bc26e392ac3265cdec2deb82698d59b580e9cded3a6e9b1e2/68747470733a2f2f692e696d6775722e636f6d2f64706d6c36594b2e706e67)

 [  ![MIT License](https://camo.githubusercontent.com/bed4b0cf615c3cb9af144926e4f5016f324c31970312bebd3797cdf0674d0843/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f747572736f64617461626173652f747572736f2d6472697665722d6c61726176656c3f636f6c6f723d463035333430)  ](LICENSE) [  ![Discord](https://camo.githubusercontent.com/32cdf422899559742ae0efd862bb2f88bc8ae52889fe24f9a7b6afc28160e0be/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f3933333037313136323638303935383938363f636f6c6f723d463035333430)  ](https://tur.so/discord-php) [  ![Contributors](https://camo.githubusercontent.com/f0ffac99c65debc87ec606e0949fb77de78892c0f39e1ac95c640ec5e66c9054/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f747572736f64617461626173652f747572736f2d6472697665722d6c61726176656c3f636f6c6f723d463035333430)  ](#contributors) [  ![Total downloads](https://camo.githubusercontent.com/0ee60c2c7b9445add9d26533332367d65320b767d174db5483e94a686638cb32/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f747572736f64617461626173652f747572736f2d6472697665722d6c61726176656c3f636f6c6f723d463035333430)  ](https://packagist.org/packages/tursodatabase/turso-driver-laravel) [  ![Version Tag](https://camo.githubusercontent.com/40d0376ddc8c125afca169adce7f7290b17e694fc59c1e1b4da54e8f8dee5c47/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f747572736f64617461626173652f747572736f2d6472697665722d6c61726176656c3f6c6162656c3d76657273696f6e26636f6c6f723d463035333430)  ](https://github.com/tursodatabase/turso-driver-laravel/tags) [  ![Testing](https://github.com/tursodatabase/turso-driver-laravel/actions/workflows/tests.yml/badge.svg)  ](https://github.com/tursodatabase/turso-driver-laravel/actions/workflows/tests.yml)

 SQLite for Production. Powered by [libSQL](https://turso.tech/libsql) and [libSQL Extension](https://github.com/tursodatabase/turso-client-php/) for PHP.

 LibSQL is a fork of SQLite and this package is **\#1 LibSQL Driver** that run natively using LibSQL Native Extension/Driver/Whatever and support Laravel Ecosystem.

---

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require tursodatabase/turso-driver-laravel
```

Then register the service provider at `bootstrap/providers.php` array:

```
return [
    App\Providers\AppServiceProvider::class,
    Turso\Driver\Laravel\LibSQLDriverServiceProvider::class, // Here
];
```

The package now include the `turso-php-installer`, so you can install the LibSQL Extension via artisan command:

```
php artisan turso-php:install

```

And you can read the all command using `php artisan | grep turso-php` or read the [manual](https://darkstation.mintlify.app/dark-extensions/tools/installer/reference)

Laravel Sail
------------

[](#laravel-sail)

Don't worry, we also provide Laravel Sail step by step guide for you read: [Sailing with LibSQL](https://darkstation.mintlify.app/dark-extensions/tools/installer/platforms/laravel-sail)

Environment Variable Overview
-----------------------------

[](#environment-variable-overview)

You need to know the additional configuration in `.env` file, which come from Laravel and which come from LibSQL Driver. And here is the overview of `.env`:

**Laravel**

```
DB_CONNECTION=libsql
DB_DATABASE=database.sqlite
```

- `DB_CONNECTION` key is represent default database connection like `libsql`, `sqlite`, `mysql`, `mariadb`, `pgsql`, and `sqlsrv`.
- `DB_DATABASE` key is represent the location of database name or in this case is database filename.

**LibSQL Driver**

```
DB_AUTH_TOKEN=
DB_SYNC_URL=
DB_SYNC_INTERVAL=5
DB_READ_YOUR_WRITES=true
DB_ENCRYPTION_KEY=
```

Create a new Turso Database [here](https://docs.turso.tech/quickstart)

### Environment Variables for Turso Driver

[](#environment-variables-for-turso-driver)

Below is a list of environment variables used to configure the Turso driver. Each variable plays a role in defining database connection and behavior:

- **`DB_AUTH_TOKEN`**
    You can generate this token using the following command:

    ```
    turso db tokens create
    ```

    Alternatively, visit your [Turso Dashboard](https://dashboard.turso.io), select the desired database, and generate the token from there.
- **`DB_SYNC_URL`**
    This URL is automatically generated by Turso when you create a new database. Retrieve the database URL using the command:

    ```
    turso db show --url
    ```
- **`DB_SYNC_INTERVAL`**
    This variable defines the interval (in seconds) at which an embedded replica synchronizes with the primary database. It ensures automatic synchronization of the database in the background.
    **Default:** `5 seconds`
    **Use case:** Keeps replicas up-to-date with minimal manual intervention.
- **`DB_READ_YOUR_WRITES`**
    Ensures that writes made by a connection are immediately visible to subsequent reads from the same connection. This is vital for maintaining consistency in distributed systems.
    **Default:** `true`
    **Use case:** Guarantees clients always see their latest writes.
- **`DB_ENCRYPTION_KEY`**
    Specifies the encryption key used for database encryption. This key is critical for securing data at rest, ensuring only authorized individuals can decrypt the database content.
    **Default:** Empty
    **Use case:** Protects sensitive data stored on disk.

Choose Your Connection Needs
----------------------------

[](#choose-your-connection-needs)

**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**To be able to use LibSQL in-memory as if you were using SQLite, simply change the following `.env`:

```
DB_CONNECTION=libsql
DB_DATABASE=:memory:

```

 **🖥 — Local Connection**To be able to use LibSQL locally as if you were using SQLite, simply change the following `.env`:

```
DB_CONNECTION=libsql
DB_DATABASE=database.sqlite

```

Ignore other LibSQL `.env` variables.

 **🌏 — Remote Connection**To use LibSQL Remote Connection only, you can define the following `.env` variables:

```
DB_CONNECTION=libsql
DB_AUTH_TOKEN=
DB_SYNC_URL=

```

 **🌱 — Remote Replica Connection (Embedded Replica)**To configure remote replica connection (embedded replica), you can simply use the following `.env`:

```
DB_CONNECTION=libsql
DB_DATABASE=database.sqlite
DB_AUTH_TOKEN=
DB_SYNC_URL=
DB_SYNC_INTERVAL=5
DB_READ_YOUR_WRITES=true
DB_ENCRYPTION_KEY=

```

That's it! How easy to make different connection using LibSQL Driver in Laravel, right?!

Database Configuration
----------------------

[](#database-configuration)

Add this configuration at `config/database.php` inside 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', ''),
],
```

> Copy and Paste and do not change it! Or try to change it and will broke your app or give you malfunction.

Usage
-----

[](#usage)

For database operation usage, everything have same interface like usual when you using `Illuminate\Support\Facades\DB` in your database model. But remember, this is LibSQL they have `sync` method that can be used when you connect with Remote Replica Connection (Embedded Replica).

```
use Illuminate\Support\Facades\DB;

// Create
DB::table('users')->insert([
    'name' => 'Budi Dalton',
    'email' => 'budi.dalton@duck.com'
]);

// Read
DB::table('users')->get();
DB::table('users')->where('id', 2)->first();
DB::table('users')->orderBy('id', 'DESC')->limit(2)->get();

// Update
DB::table('users')->where('id', 2)->update(['name' => 'Doni Mandala']);

// Delete
DB::table('users')->where('id', 2)->delete();

// Transaction
try {
    DB::beginTransaction();

    $updated = DB::table('users')->where('id', 9)->update(['name' => 'Doni Kumala']);

    if ($updated) {
        echo "It's updated";
        DB::commit();
    } else {
        echo "Not updated";
        DB::rollBack();
    }

    $data = DB::table('users')->orderBy('id', 'DESC')->limit(2)->get();
    dump($data);
} catch (\Exception $e) {
    DB::rollBack();
    echo "An error occurred: " . $e->getMessage();
}

// Sync
DB::sync();
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Contributors
------------

[](#contributors)

[![Contributors](https://camo.githubusercontent.com/60d19f53dff152977fa5f300301612afe8e80f1092e6abd498abf24c4135dbd7/68747470733a2f2f636f6e747269622e6e6e2e63692f6170693f6e6f5f626f743d74727565267265706f3d747572736f64617461626173652f747572736f2d6472697665722d6c61726176656c)](https://camo.githubusercontent.com/60d19f53dff152977fa5f300301612afe8e80f1092e6abd498abf24c4135dbd7/68747470733a2f2f636f6e747269622e6e6e2e63692f6170693f6e6f5f626f743d74727565267265706f3d747572736f64617461626173652f747572736f2d6472697665722d6c61726176656c)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance71

Regular maintenance activity

Popularity39

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 57.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~14 days

Recently: every ~23 days

Total

26

Last Release

356d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/32319439?v=4)[Imam Ali Mustofa](/maintainers/darkterminal)[@darkterminal](https://github.com/darkterminal)

---

Top Contributors

[![darkterminal](https://avatars.githubusercontent.com/u/32319439?v=4)](https://github.com/darkterminal "darkterminal (168 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (58 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (54 commits)")[![ineersa](https://avatars.githubusercontent.com/u/4228843?v=4)](https://github.com/ineersa "ineersa (7 commits)")[![avenjamin](https://avatars.githubusercontent.com/u/869534?v=4)](https://github.com/avenjamin "avenjamin (2 commits)")[![eznix86](https://avatars.githubusercontent.com/u/26553194?v=4)](https://github.com/eznix86 "eznix86 (2 commits)")[![notrab](https://avatars.githubusercontent.com/u/950181?v=4)](https://github.com/notrab "notrab (1 commits)")[![peteradeojo](https://avatars.githubusercontent.com/u/60135915?v=4)](https://github.com/peteradeojo "peteradeojo (1 commits)")

---

Tags

databasedriverlaravellaravel-packagephpsqlitetursolaraveltursolibsqllibsql-driver-laravelturso-driver-laraveltursodatabase

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/tursodatabase-turso-driver-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/tursodatabase-turso-driver-laravel/health.svg)](https://phpackages.com/packages/tursodatabase-turso-driver-laravel)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spatie/laravel-model-flags

Add flags to Eloquent models

4301.1M1](/packages/spatie-laravel-model-flags)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[spatie/laravel-sql-commenter

Add comments to SQL queries made by Laravel

1931.4M1](/packages/spatie-laravel-sql-commenter)[spatie/laravel-deleted-models

Automatically copy deleted records to a separate table

409109.8k4](/packages/spatie-laravel-deleted-models)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

203330.1k2](/packages/wnx-laravel-backup-restore)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
