Hello Punk! π Yes, I am again. Sorry for wasting your time reading this pretty blog/article/whatever.
It's re-write?
Yes! But, the first blog is just copy-paste from README.md
file. Here the actual story what I've done with Laravel.
PHP Community it's huge! But when Turso/LibSQL Database came, they did not support PHP, because they doesn't have developer that really into in PHP and LibSQL build using Rust, so they have Rust only binary.
For the first launch, They have Rust, Go, Python and TypeScript/JS Official SDKs.
However, Turso provides the HTTP SDK as a creation tool for developers who want to create an SDK that is not yet supported by the official SDK.
From there, several Community SDKs emerged, most of which use the HTTP SDK. When using HTTP SDK so database interact with Remote Database and the developer still use SQLite for In-Memory or Local Interaction. Is it wrong? Of course not, I also did the same thing at first. This is an art, so people can have their own interpretation.
Here is my first Turso/LibSQL Library that support Turso HTTP SDK and Platform API.
But, Turso also have a Embedded Replica that sync local database with remote database on the edge, how do sync then?
Don't worry I am also create a Stupid Worker which will make you poor when using it with the number of interactions reading and writing databases from local to remote via HTTP Protocol.
darkterminal / turso-syncd
Turso Database Background Sync
~ TursoSyncd ~
Turso Dabatabase Background Sync in the Background
Installation
Globally Install
composer global require darkterminal/turso-syncd
or you can install locally within your porject:
composer require darkterminal/turso-syncd
Usage
turso-syncd --database=<database_name> --organization=<organization_name> --token=<token> [--file_recorder=<file>] [--action_log_file=<file>] [--errors_log_file=<file>]
Options
-
--database=<database_name>
or-d
: The name of the database. -
--organization=<organization_name>
or-o
: The name of the organization. -
--token=<token>
or-t
: The token for authentication. -
--file_recorder=<file>
: Specify file recorder. -
--action_log_file=<file>
: Specify action log file. -
--errors_log_file=<file>
: Specify errors log file. -
--help
: Display this help message.
Extend in Your Own Daemon
<?php
use Darkterminal\TursoSyncd;
require_once "vendor/autoload.php";
$databaseName = "your-database-name";
$organizationName = "your-organization-name";
$token = "your-turso-token";
$config = [
'file_recorder
β¦Back to This!
When using HTTP SDK so database interact with Remote Database and the developer still use SQLite for In-Memory or Local Interaction. Is it wrong? Of course not, I also did the same thing at first.
But if we use SQLite to create an In-Memory or Local File Connection, it will reduce the artistic value of LibSQL, because with Binary LibSQL, we can create 4 different types of database connections.
- In-Memory Connection
- Local Connection
- Remote Connection
- Remote Replica (Embedded Replica) Connection
That's why I was challenged to create a Native Extension/Driver/Whatever to get the full power of what Turso/LibSQL has to offer.
You can read the README.md
when you landed at my Laravel Driver repository in GitHub
tursodatabase / turso-driver-laravel
Turso Driver for Laravel with Native libSQL
Turso + Laravel
SQLite for Production. Powered by libSQL and libSQL Extension for PHP
Turso Β· Quickstart Β· Examples Β· Docs Β· Discord Β· Blog & Tutorials
A LibSQL Driver for 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
Before using this package, you need to install and configure LibSQL Native Extension for PHP. You can download from LibSQL Extension - Release
- Download based on you distribution (Linux/Macos/Darwin)
- The archive is contains the extension and
libsql_php_extension.stubs.php
- Save the extension file in your desire directory
- 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. - Configure
php.ini
file and added the extension address with relative path that pointed to the extension - Enjoy!
orβ¦
I just want to bring some joy out of the mess I've made writing code while dancing to the music I hate the most.
You can read Turso Documentation
If you like this project and want to support my activities, you can sponsor me on GitHub. Sorry and thank you for taking the time to read.
Top comments (0)