Search by

dolthub / doltlite-php

dolthub

DoltLite for PHP: SQLite with Git-style version control (branch, commit, merge, diff), bound over FFI with the SQLite3-class API shape.

Package info

github.com/dolthub/doltlite-php

Homepage

pkg:composer/dolthub/doltlite-php

Statistics

Installs: 40

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.50.12 2026-09-21 17:51 UTC

This package is auto-updated.

Last update: 2026-09-21 17:52:45 UTC


README

The installable package is distributed through dolthub/doltlite-php, whose contents — including the prebuilt lib/ binaries — are pushed by dolthub/doltlite's release workflow on every tagged release. The package source lives in that repository under packaging/composer/; send issues and pull requests there.

DoltLite for PHP: SQLite with Git-style version control — branch, commit, merge, and diff your relational data. The binding runs over PHP's FFI extension against the libdoltlite shared library bundled with this package, and mirrors the shape of PHP's built-in SQLite3 classes so existing code ports by search-and-replace.

Requirements

  • PHP >= 8.1 with the ffi extension enabled (php -m | grep FFI). On hardened hosts check ffi.enable; the CLI default allows FFI.
  • Linux (x86_64/arm64) or macOS (arm64). The package bundles a prebuilt libdoltlite per platform; DOLTLITE_PHP_LIB=/path/to/lib overrides resolution for anything else.
  • Windows is not supported. Composer will install the package there, but releases do not reliably include libdoltlite.dll and nothing is tested on Windows, so the first new Doltlite3(...) fails inside FFI::cdef() with a loader error. DOLTLITE_PHP_LIB pointing at a DLL you built yourself is an untested escape hatch, not support.

Install

composer require dolthub/doltlite-php

Use

The API is SQLite3 with the prefix swapped: Doltlite3, Doltlite3Stmt, Doltlite3Result, and DOLTLITE3_* constants. Errors always raise Doltlite\Exception.

use Doltlite\Doltlite3;

$db = new Doltlite3('app.db');
$db->exec('CREATE TABLE users(id INTEGER PRIMARY KEY, name TEXT)');

$stmt = $db->prepare('INSERT INTO users(name) VALUES (:name)');
$stmt->bindValue(':name', 'Ada');
$stmt->execute();

// Version control is plain SQL on the same connection.
$db->querySingle("SELECT dolt_commit('-A', '-m', 'add ada')");
$db->querySingle("SELECT dolt_checkout('-b', 'experiment')");
$db->exec("UPDATE users SET name = 'Grace' WHERE id = 1");
$db->querySingle("SELECT dolt_commit('-A', '-m', 'rename')");
$db->querySingle("SELECT dolt_checkout('main')");
$db->querySingle("SELECT dolt_merge('experiment')");

$log = $db->query('SELECT commit_hash, message FROM dolt_log');
while (($commit = $log->fetchArray(DOLTLITE3_ASSOC)) !== false) {
    echo "{$commit['commit_hash']} {$commit['message']}\n";
}

Every DoltLite feature — branches, merges, diffs (dolt_diff, dolt_log, dolt_branches tables), remotes (dolt_push/dolt_pull/dolt_clone) — is reachable through SQL; no binding-specific API is needed. See the DoltLite documentation for the SQL surface.

Differences from SQLite3

  • Errors always throw Doltlite\Exception; there is no warnings mode (matching where PHP itself is headed with SQLite3).
  • openBlob, createFunction, createAggregate, createCollation, and setAuthorizer are not implemented. File an issue if you need them.