Databases for PHP multi-tenant AI Apps.
Turso · Docs · Quickstart · SDK Reference · Blog & Tutorials
- 🔌 Works offline with Embedded Replicas
- 🌎 Works with remote Turso databases
- ✨ Works with Turso AI & Vector Search
Warning
This SDK is currently in technical preview. Join us in Discord to report any issues.
composer require turso/libsql
The example below uses Embedded Replicas and syncs data every 1000ms from Turso.
<?php
use Libsql\Database;
$db = new Database(
path: 'local.db',
url: getenv('TURSO_DATABASE_URL'),
authToken: getenv('TURSO_AUTH_TOKEN')
syncInterval: 1000
);
$conn = $db->connect();
$createUsers = "
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT
);
INSERT INTO users (name) VALUES ('Iku');
";
$conn->executeBatch($createUsers);
$conn->query("SELECT * FROM users WHERE id = ?", [1])->fetchArray();
Visit our official documentation.
Join us on Discord to get help using this SDK. Report security issues via email.
See the contributing guide to learn how to get involved.