PHPackages                             mis3085/turso-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. mis3085/turso-laravel

ActiveLibrary

mis3085/turso-laravel
=====================

A Turso/LibSQL database driver for Laravel

v2.0.0(yesterday)02↑2900%MITPHPPHP ^8.2CI passing

Since Aug 24Pushed yesterdayCompare

[ Source](https://github.com/mis3085/turso-laravel)[ Packagist](https://packagist.org/packages/mis3085/turso-laravel)[ Docs](https://github.com/mis3085/turso-laravel)[ GitHub Sponsors](https://github.com/richan-fongdasen)[ RSS](/packages/mis3085-turso-laravel/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (20)Versions (3)Used By (0)

A Turso database driver for Laravel
===================================

[](#a-turso-database-driver-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/34ba1438f87028bf7af414598c5c0a50f03a38bf1dc94f62bb55cfdb9e9bd147/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6973333038352f747572736f2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mis3085/turso-laravel)[![License: MIT](https://camo.githubusercontent.com/c860a9e10827ff3648be4c32339b6f056585e919301a13dff307bf4c4c62a1bd/68747470733a2f2f706f7365722e707567782e6f72672f6d6973333038352f747572736f2d6c61726176656c2f6c6963656e73652e737667)](https://opensource.org/licenses/MIT)[![PHPStan](https://github.com/mis3085/turso-laravel/actions/workflows/phpstan.yml/badge.svg?branch=main)](https://github.com/mis3085/turso-laravel/actions/workflows/phpstan.yml)[![Unit Tests](https://github.com/mis3085/turso-laravel/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/mis3085/turso-laravel/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/81410769339b9f48e2859a7f148fdbf08470dfb76e15ae557b808bd0dd42adac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6973333038352f747572736f2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mis3085/turso-laravel)

This package provides a Turso database driver for Laravel, allowing you to use Turso as your database backend in Laravel applications. The driver communicates with the Turso database server using an HTTP client.

This is a maintained fork of [richan-fongdasen/turso-laravel](https://github.com/richan-fongdasen/turso-laravel), kept alive to support current Laravel versions.

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Node.js 18 or higher

LaravelPHPPackage11.x8.2 - 8.42.x12.x8.2 - 8.52.x13.x8.3 - 8.52.xInstallation
------------

[](#installation)

You can install the package via Composer:

```
composer require mis3085/turso-laravel
```

To use Turso as your database driver in Laravel, append the following configuration to the `connections` array in your `config/database.php` file:

```
'turso' => [
    'driver'                  => 'turso',
    'db_url'                  => env('DB_URL', 'http://localhost:8080'),
    'access_token'            => env('DB_ACCESS_TOKEN'),
    'db_replica'              => env('DB_REPLICA'),
    'prefix'                  => env('DB_PREFIX', ''),
    'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
    'sticky'                  => env('DB_STICKY', true),
],
```

### Publishing Configuration and Sync Script

[](#publishing-configuration-and-sync-script)

Publish the configuration file and sync script by running the following command:

```
php artisan vendor:publish --provider="Mis3085\Turso\TursoLaravelServiceProvider"
```

The above command publishes the following files:

- `config/turso-laravel.php`
- `turso-sync.mjs`

The content of the `config/turso-laravel.php` file should look like this:

```
return [
    'client' => [
        'connect_timeout' => env('TURSO_CONNECT_TIMEOUT', 2),
        'timeout'         => env('TURSO_REQUEST_TIMEOUT', 5),
    ],

    'sync_command' => [
        'node_path'       => env('NODE_PATH'), // Full path to the node executable. E.g: /usr/bin/node
        'script_filename' => 'turso-sync.mjs',
        'script_path'     => realpath(__DIR__ . '/..'),
        'timeout'         => 60,
    ],
];
```

You may need to set the `NODE_PATH` environment variable to the path of your Node.js executable. This is required to run the sync script.

### Installing Node.js Dependencies

[](#installing-nodejs-dependencies)

The Turso database driver requires Node.js to run the sync script. Install the Node.js dependencies by running the following command:

```
npm install @libsql/client
```

Configuration
-------------

[](#configuration)

In Laravel applications, the database driver configuration is stored in your `.env` file. Here are the available configurations for the Turso database driver:

```
DB_CONNECTION=turso
DB_URL=http://localhost:8080
DB_ACCESS_TOKEN=
DB_REPLICA=
DB_PREFIX=
DB_FOREIGN_KEYS=true
DB_STICKY=true
```

ENV Variable NameDescriptionDB\_URLThe Turso database server URL. E.g: `https://[databaseName]-[organizationName].turso.io`DB\_ACCESS\_TOKEN(Optional) The access token to access the Turso database server.DB\_REPLICA(Optional) The full path to the local embedded replica database file. E.g: `/tmp/turso.sqlite`DB\_PREFIX(Optional) The database table prefix.DB\_FOREIGN\_KEYSEnable or disable foreign key constraints, default is `true`.DB\_STICKYEnable or disable sticky connections while performing write operations, default is `true`.Usage
-----

[](#usage)

For local development, you can use the local Turso database server provided by the Turso team. Refer to the [Turso CLI documentation](https://docs.turso.tech/local-development#turso-cli) for instructions on running the local Turso database server.

The Turso database driver should work as expected with Laravel's Query Builder and Eloquent ORM. Here are some examples:

```
use App\Models\User;
use Illuminate\Support\Facades\DB;

// Using Query Builder
$users = DB::table('users')->orderBy('name')->get();

// Using Eloquent ORM
$users = User::with('posts')->orderBy('name')->get();
```

### Embedded Replica Support

[](#embedded-replica-support)

The driver supports the embedded replica feature. If you're unfamiliar with this feature, refer to the [Turso embedded replica article](https://turso.tech/blog/introducing-embedded-replicas-deploy-turso-anywhere-2085aa0dc242) for more information.

### Running the sync script from artisan command

[](#running-the-sync-script-from-artisan-command)

Run the sync script manually using the following Artisan command:

```
php artisan turso:sync
```

> You may encounter an error if the path to the replica database does not exist. This is expected when the replica database has not been created yet.

### Running the sync script programmatically

[](#running-the-sync-script-programmatically)

Run the sync script programmatically using the following code:

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

if ( DB::hasModifiedRecords() ) {
    // Run the sync script immediately
    DB::sync();

    // Run the sync script in the background
    DB::backgroundSync();
}

// Sync on the specific connection
DB::connection('turso')->sync();
DB::connection('turso')->backgroundSync();

// Sync on all of the turso database connections
Turso::sync();
Turso::backgroundSync();
```

Debugging
---------

[](#debugging)

To debug the HTTP requests and responses sent and received by the Turso database client, enable the debugging feature as follows:

```
// Enabling query log on default database connection
DB::enableQueryLog();

// Enabling query log on specific connection
DB::connection('turso')->enableQueryLog();

// Perform some queries
DB::table('users')->get();

// Get the query log for default database connection
DB::getQueryLog();

// Get the query log for specific connection
DB::connection('turso')->getQueryLog();
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

### Local development

[](#local-development)

The test suite needs a local Turso-compatible server and a PHP version matching the target Laravel release. Docker is used for both:

```
# Start the local database server (required by the feature tests)
docker compose up -d turso

# Run the whole suite against the highest supported stack (Laravel 13, PHP 8.3+)
docker compose run --rm tests sh -c "composer update && vendor/bin/pest"
```

On a machine with a native PHP that satisfies the version table above, you can also run the suite directly:

```
composer install
vendor/bin/pest
```

To test against a specific Laravel version locally, pin it the same way the CI matrix does:

```
composer require "orchestra/testbench:^9.0" --dev --no-interaction --no-update && composer update && vendor/bin/pest
```

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [Richan Fongdasen](https://github.com/richan-fongdasen) — original author
- [4lun](https://github.com/4lun) — the Laravel 12/13 compatibility work in [upstream PR #25](https://github.com/richan-fongdasen/turso-laravel/pull/25)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance100

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

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

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/901cd3d3c892f269122329d69542994a208cf30b6345c0338293287ae4acb4f6?d=identicon)[mis3085](/maintainers/mis3085)

---

Top Contributors

[![richan-fongdasen](https://avatars.githubusercontent.com/u/5222595?v=4)](https://github.com/richan-fongdasen "richan-fongdasen (49 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (8 commits)")[![mis3085](https://avatars.githubusercontent.com/u/17059877?v=4)](https://github.com/mis3085 "mis3085 (5 commits)")

---

Tags

laraveltursolibsqlturso-laravel

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.1k4.6M337](/packages/laravel-ai)[laravel/scout

Laravel Scout provides a driver based solution to searching your Eloquent models.

1.7k57.2M687](/packages/laravel-scout)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9922.4M147](/packages/roots-acorn)[illuminate/queue

The Illuminate Queue package.

20433.0M1.8k](/packages/illuminate-queue)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

265.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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