DEV Community

Cover image for A Lambo - LibSQL Native Extension/Driver/Whatever
Imam Ali Mustofa
Imam Ali Mustofa

Posted on

A Lambo - LibSQL Native Extension/Driver/Whatever

Hello Punk!

I build bunch of Turso/LibSQL Client for fun experiment and I love it! I am also build:

  • TursoHTTP (that mentioned by @defenestrator) it's connect Remote Turso Database via HTTP
  • TursoSyncd it's stupid worker that sync local database to remote database via HTTP and it will make you poor for a long usage πŸ˜…
  • LibSQL Client PHP Turso + PHP SDK for Native LibSQL via FFI it's only support Local Connection, Remote Connection over HTTP, and Remote Replica. Also you can check this at Turso Client SDK
  • LibSQL PHP Ext LibSQL PHP Extension via FFI - Core Dependency for LibSQL Client PHP. This extension behave like SQLite driver but it's LibSQL!

The Final

I've done building a Native LibSQL Extension/Driver/Whatever and I am try to package this driver into Laravel (but I need some help here πŸ˜„). Since this is not an official PHP extension, I need to make it installable in the project.

What I've Done?

This weekend May, 19 2024, I am done and re-think about what I am talking before. I just drunk stupid person but still; I am handsome. The LibSQL PHP Ext can be use stand-alone, this is the core dependency of LibSQL Client PHP.

Requirements

  • Linux or Darwin OS
  • C/C++ Compiler
  • jq
  • Rust Installed
  • PHP Installed
  • FFI Extension is Enabled (Why? I read the C heder definition from wrapper)

🚨 DON'T WORRY ABOUT REQUIREMENTS 🚨

Everything will be prepared when you install this extension. But, if you encountered an error; create an issue.

So with LibSQL PHP Ext features we can create custom LibSQL Driver for Laravel (but it's not support remote), remote connection still handle via HTTP SDK from LibSQL Client PHP.

So let me know, who want to join the party πŸŽ‰ πŸš€

NOTE This party only for Linux & Mac/Darwin. But Windows can join when using WSL πŸ˜„

Another Options

I am also create native extension LibSQL Extension, so you can download and install them and configured in php.ini but still, it's not based on PDO driver.


Recent Updates

Make sure you follow the latest update from My X Thread!

23 Mei 2024 - LibSQL Driver Laravel - LibSQL Remote Replica Connection

And now LibSQL Driver Laravel can perform database sync operations using traditional Illuminate\Support\Facades\DB for LibSQL Remote Replica Connection:

  • Migration and Seeding
  • CRUD
  • Transaction
  • Sync

Here the screenshot of fresh Laravel app database migration and data:

  1. Local database.sqlite tables

Local  raw `database.sqlite` endraw  tables

  1. Remote database tables at Turso Dashboard

Remote database tables at Turso Dashboard

  1. Users Data from Seeder Database at Turso Dashboard

Users Data from Seeder Database at Turso Dashboard

  1. Users Data From in Local database.sqlite File

Users Data From in Local  raw `database.sqlite` endraw  File

23 May 2024 - LibSQL Driver Laravel - LibSQL Local Connection

And now LibSQL Driver Laravel can perform database operations using traditional Illuminate\Support\Facades\DB for LibSQL Local Connection:

  • Migration and Seeding
  • CRUD
  • Transaction

22 May 2024 - LibSQL Driver Laravel - Initial

I created LibSQL Driver Laravel still work in progress. It's will used Illuminate\Support\Facades\DB to interact with LibSQL native driver.

Top comments (0)