A PHP SDK for interacting with Litebase, an open source distributed database built on SQLite, distributed file systems, and object storage.
You can install the package via composer:
composer require litebase/litebase-phpuse Litebase\Configuration;
use Litebase\LitebasePDO;
$pdo = new LitebasePDO([
'host' => 'localhost',
'port' => 8888,
'token' => 'your_api_token',
'database' => 'your_database_name/main',
]);
$statement = $pdo->prepare('SELECT * FROM users WHERE id = ?');
$statement->execute([1]);
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
print_r($row);
}
// Use transactions
$pdo = $pdo->beginTransaction();
try {
$statement = $pdo->prepare('INSERT INTO users (name, email) VALUES (?, ?)');
$statement->execute(['John Doe', 'john@example.com']);
$statement = $pdo->prepare('INSERT INTO logs (user_id, action) VALUES (?, ?)');
$statement->execute([$pdo->lastInsertId(), 'user_created']);
$pdo->commit();
} catch (\Exception $e) {
$pdo->rollBack();
throw $e;
}Please see CONTRIBUTING for details.
You can run the tests:
composer testIntegration tests require a running Litebase Server. When running integration tests, a server will be automatically started using Docker. You can run the tests with:
composer test-integrationPlease see CODE OF CONDUCT for details.
All security related issues should be reported directly to security@litebase.com.
Litebase is open-sourced software licensed under the MIT License.