This repository is no longer under maintenance and has been moved to
the official Turso Database repository under the name Turso Client PHP
Native libSQL Driver for PHP
Build by Handsome Person from 🇮🇩
@panggilmeiam or .darkterminal
Turso · Quickstart · Examples · Docs · Discord · Blog & Tutorials
LibSQL PHP Driver/Extension/Whatever designed to seamlessly handle local, remote, and remote replica/embedded replica connections, offering versatility and efficiency for your application's data management needs. With an intuitive interface and flexible configuration options, LibSQL empowers developers to effortlessly integrate database operations into your PHP projects.
Download the latest build extension/driver binary you can see at Release page. It's available for:
- Linux
- Mac/Darwin
- Windows (still struggle)
- Extract the archive
- Locate somewhere in your machine
- Copy a relative path that address that extension/driver
- Open
php.ini
search;extension
if you usingnano
(ctrl+w
) then searching for it - add in the next-line
extension=liblibsql_php.so
(in Linux) without;
at the begining
Check on your console/terminal
php --m | grep libsql
Remember, this is not a library or ORM, this is the native extension for LibSQL.
<?php
// Instanciate
$db = new LibSQL(":memory:");
// Create table
$sql = "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER)";
$db->execute($sql);
// Insert data
$db->execute("INSERT INTO users (name. age) VALUES ('Diana Hooggan', 24)");
// Read data
$results = $db->query("SELECT * FROM users");
// Display data
foreach ($results['rows'] as $row) {
echo "ID: " . $row['id'] . ", Name: " . $row['name'] . ", Age: " . $row['age'] . "\n";
}
// Close database
$db->close();
How easy is that!?