PHPackages                             darkterminal/libsql-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. darkterminal/libsql-driver-laravel

Abandoned → [tursodatabase/turso-driver-laravel](/?search=tursodatabase%2Fturso-driver-laravel)ArchivedLibrary[Database &amp; ORM](/categories/database)

darkterminal/libsql-driver-laravel
==================================

A LibSQL Driver for Laravel

v0.0.1(2y ago)1016MITPHPPHP ^8.2

Since May 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/darkterminal/libsql-driver-laravel)[ Packagist](https://packagist.org/packages/darkterminal/libsql-driver-laravel)[ Docs](https://github.com/darkterminal/libsql-driver-laravel)[ GitHub Sponsors](https://github.com/darkterminal)[ RSS](/packages/darkterminal-libsql-driver-laravel/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)Dependencies (13)Versions (2)Used By (0)

🚨 THIS REPOSITORY IS READ-ONLY 🚨
================================

[](#-this-repository-is-read-only-)

### This repository is no longer under maintenance and has been moved to
 the official [Turso Database](https://github.com/tursodatabase) repository under the name [Turso Driver Laravel](https://github.com/tursodatabase/turso-driver-laravel)

[](#this-repository-is-no-longer-under-maintenance-and-has-been-moved-to--the-official-turso-database-repository-under-the-name-turso-driver-laravel)

 [ ![Turso + Laravel](https://camo.githubusercontent.com/69dbdd4eae81d2974b9c963a01526e29caa2bf6a88197803ec575fe9a86a5433/68747470733a2f2f692e696d6775722e636f6d2f5432707a4a69642e706e67)](https://darkterminal.mintlify.app/dark-packages/libsql-driver-laravel/readme)

### Turso + Laravel

[](#turso--laravel)

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

 [**Turso**](https://turso.tech) · [**Quickstart**](https://darkterminal.mintlify.app/dark-packages/libsql-driver-laravel/readme) · [**Examples**](https://darkterminal.mintlify.app/dark-packages/libsql-driver-laravel/readme) · [**Docs**](https://darkterminal.mintlify.app/dark-packages/libsql-driver-laravel/readme) · [**Discord**](https://discord.com/invite/4B5D7hYwub) · [**Blog &amp; Tutorials**](https://blog.turso.tech/)

---

A LibSQL Driver for Laravel
===========================

[](#a-libsql-driver-for-laravel)

 [![Latest Version on Packagist](https://camo.githubusercontent.com/7e796e315da54055f5e4325471786578c1f1082a57cfc05063eb54fc6344a323/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6461726b7465726d696e616c2f6c696273716c2d6472697665722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/darkterminal/libsql-driver-laravel) [![GitHub Tests Action Status](https://camo.githubusercontent.com/6367294d07f7bfee2baedcc329843aad12d888b54b1e41af55d8fa45285b4f11/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6461726b7465726d696e616c2f6c696273716c2d6472697665722d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/darkterminal/libsql-driver-laravel/actions?query=workflow%3Arun-tests+branch%3Amain) [![GitHub Code Style Action Status](https://camo.githubusercontent.com/a3f3af55e5135b7179e959795ed57ec255db170eda02536bd6831e50e8a33133/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6461726b7465726d696e616c2f6c696273716c2d6472697665722d6c61726176656c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/darkterminal/libsql-driver-laravel/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain) [![Total Downloads](https://camo.githubusercontent.com/4bc09655f00f796bdce4f3b2ae20c877a4d6118eacbafb64459234804222a3cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6461726b7465726d696e616c2f6c696273716c2d6472697665722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/darkterminal/libsql-driver-laravel)

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.

Requirement
-----------

[](#requirement)

Before using this package, you need to install and configure LibSQL Native Extension for PHP. You can download from [LibSQL Extension - Release](https://github.com/darkterminal/libsql-extension)

1. Download based on you distribution (Linux/Macos/Darwin)
2. The archive is contains the extension and `libsql_php_extension.stubs.php`
3. Save the extension file in your desire directory
4. Save the `libsql_php_extension.stubs.php` in your project or somewhare that can help you to use stand-alone LibSQL driver as an IDE helper. By default this stubs is come inside this package.
5. Configure `php.ini` file and added the extension address with relative path that pointed to the extension
6. Enjoy!

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

[](#installation)

You can install the package via composer:

```
composer require darkterminal/libsql-driver-laravel
```

You can publish package vendor using this command:

```
php artisan vendor:publish --tag=libsql-driver-laravel
```

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=
DB_REMOTE_ONLY=false
```

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

- `DB_AUTH_TOKEN` - You can generate using `turso db tokens create ` command or you can visit your Turso Dashboard and select database you want to used and generate the token from there.
- `DB_SYNC_URL` - This generate by Turso when you craete a new database, you can get the database URL by using this command `turso db show --url `
- `DB_SYNC_INTERVAL` - This variable defines the interval at which an embedded replica synchronizes with the primary database. It sets a duration for automatic synchronization of the database in the background. When configured, the embedded replica will periodically sync its local state with the state of the primary database to ensure it has the latest data. This is particularly useful for ensuring that replicas remain up-to-date with minimal manual intervention. Default is: 5 seconds.
- `DB_READ_YOUR_WRITES` - This variable configures the database connection to ensure that writes made by a connection are immediately visible to subsequent read operations initiated by the same connection. This is important in distributed systems to ensure consistency from the perspective of the writing process. When enabled, after a write operation is performed, any reads that follow from the same connection will see the results of that write. **This option is typically enabled by default** to ensure that clients always see their latest writes.
- `DB_ENCRYPTION_KEY` - This variable is defined for specifying the encryption key used in database encryption. It represents the secret key that is used to encrypt and decrypt the database content, ensuring that the data stored in the database is protected and can only be accessed by individuals who possess the correct key. This key is a critical component of encryption-at-rest strategies, where the goal is to secure data while it is stored on disk, preventing unauthorized access. Default is: empty.
- `DB_REMOTE_ONLY` - This variable is define to use remote connection only, if you only want to read and write the database from remote database. Default: false.

Configure The Connection
------------------------

[](#configure-the-connection)

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

### In-Memory Connection

[](#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

[](#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

[](#remote-connection)

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

```
DB_CONNECTION=libsql
DB_AUTH_TOKEN=
DB_SYNC_URL=
DB_REMOTE_ONLY=true
```

### Remote Replica Connection (Embedded Replica)

[](#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=
DB_REMOTE_ONLY=false
```

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',
    'url' => 'file:' . env('DB_DATABASE', database_path('database.sqlite')),
    'authToken' => env('DB_AUTH_TOKEN', ''),
    'syncUrl' => env('DB_SYNC_URL', ''),
    'syncInterval' => env('DB_SYNC_INTERVAL', 5),
    'read_your_writes' => env('DB_READ_YOUR_WRITES', true),
    'encryptionKey' => env('DB_ENCRYPTION_KEY', ''),
    'remoteOnly' => env('DB_REMOTE_ONLY', false),
    'database' => null,
    'prefix' => '',
],
```

> 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::connection('libsql')->table('users')->craete([
    'name' => 'Budi Dalton',
    'email' => 'budi.dalton@duck.com'
]);

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

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

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

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

    $updated = DB::connection('libsql')->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::connection('libsql')->table('users')->orderBy('id', 'DESC')->limit(2)->get();
    dump($data);
} catch (\Exception $e) {
    DB::rollBack();
    echo "An error occurred: " . $e->getMessage();
}

// Sync
DB::connection('libsql')->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.

Credits
-------

[](#credits)

- [Imam Ali Mustofa](https://github.com/:darkterminal)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

770d 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 (9 commits)")

---

Tags

databaseextensionlaravellibsqllibsql-client-phpphptursolaravellibsql-driver-laravel

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/darkterminal-libsql-driver-laravel/health.svg)

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[wnx/laravel-backup-restore

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

213420.1k2](/packages/wnx-laravel-backup-restore)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

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