Skip to content

PHP SDK for Litebase, an open source distributed database built on SQLite and backed by distributed file systems and object storage

License

Notifications You must be signed in to change notification settings

litebase/litebase-php

Litebase PHP SDK (Alpha)

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.

About

PHP SDK for Litebase, an open source distributed database built on SQLite and backed by distributed file systems and object storage

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •