A community-driven PHP SDK for libSQL — the SQLite fork designed for the edge, replication, and production workloads.
turso-client-php (libSQL Extension) brings the power of libSQL to PHP applications. It’s more than just SQLite — with built-in support for remote connections, replicas, sync, offline writes, and transactions.
✨ Key features:
- 🚀 Works with SQLite and libSQL
- 🔌 Multiple connection modes
- local
- in-memory
- remote
- remote replica
- offline-writes also support for libsql-server (sqld)
- 🔒 Transactions, prepared statements, and batch execution
- 🐘 Native PHP extension built in Rust for speed
- 🐳 Easy setup with
turso-php-installer
| PHP Versions | Build Versions |
|---|---|
| 8.1 | TS / NTS |
| 8.2 | TS / NTS |
| 8.3 | TS / NTS |
| 8.4 | TS / NTS |
| 8.5 | TS / NTS |
TS = Thread Safe, NTS = Non Thread Safe
✅ Supported on Linux, macOS, Windows, WSL
<?php
$libsql = new LibSQL("file:example.db");
// Create a table
$libsql->execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)");
// Insert a row
$libsql->execute("INSERT INTO users (name) VALUES (?)", ["Alice"]);
// Query data
$result = $libsql->query("SELECT * FROM users");
$rows = $result->fetchArray(LibSQL::LIBSQL_ASSOC);
foreach ($rows as $row) {
echo $row["id"] . " - " . $row["name"] . PHP_EOL;
}➡️ See Quick Start Guide for more details.
Installing the extension should be not complecated, it's easy and like using Composer Package Installer.
Auto Installer
turso-php-installer is a Composer package capable of executing various commands related to libSQL, simplifying the development process, and making it easier to simulate in a local environment.
composer global require darkterminal/turso-php-installerAdd the binary to your PATH:
export COMPOSER_BIN_DIR=$(composer config --global home)/vendor/binRun the installer in interactive mode:
turso-php-installer installOr non-interactive (example for PHP 8.3):
turso-php-installer install -n --php-version=8.3📦 For alternative methods (manual build, Docker, ARM64), check Installation Docs.
👉 Full documentation available in the docs/ folder.
Requirements:
- PHP ≥ 8.1
- Rust nightly toolchain
- Git
- Docker & Docker Compose (for containerized dev)
Build from source:
git clone git@github.com:<username>/turso-client-php.git
cd turso-client-php
rustup toolchain install nightly
rustup default nightly
cargo buildOr inside Docker:
make compose/up
# or for arm64
make compose-arm64/upFor available commands:
make help- 💬 Join us on Discord
- 🐛 Report issues on GitHub Issues
- 🤝 Contributions welcome! See Contributing Guide
This project is open-sourced under the MIT License.
