Skip to content

tursodatabase/libsql-php

Repository files navigation

libSQL PHP

libSQL PHP

Databases for PHP multi-tenant AI Apps.

Turso · Docs · Quickstart · SDK Reference · Blog & Tutorials

MIT License Discord Contributors Total downloads Examples

Features

Warning

This SDK is currently in technical preview. Join us in Discord to report any issues.

Install

composer require turso/libsql

Quickstart

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();

Documentation

Visit our official documentation.

Support

Join us on Discord to get help using this SDK. Report security issues via email.

Contributors

See the contributing guide to learn how to get involved.

Contributors

good first issue