litebase/litebase-php

Litebase PHP SDK

Fund package maintenance!
litebase

Installs: 30

Dependents: 1

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/litebase/litebase-php

v0.5.5 2025-11-26 21:23 UTC

This package is auto-updated.

Last update: 2025-11-26 21:24:29 UTC


README

tests GitHub License

A PHP SDK for interacting with Litebase, an open source distributed database built on SQLite, distributed file systems, and object storage.

Installation

You can install the package via composer:

composer require litebase/litebase-php

Usage

use 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;
}

Contributing

Please see CONTRIBUTING for details.

Testing

You can run the tests:

composer test

Integration 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-integration

Code of Conduct

Please see CODE OF CONDUCT for details.

Security

All security related issues should be reported directly to security@litebase.com.

License

Litebase is open-sourced software licensed under the MIT License.