bluzelle/bluzelle-php

A PHP library to interact with Bluzelle Blockchain Database

dev-master 2018-07-11 01:51 UTC

This package is not auto-updated.

Last update: 2024-04-18 16:57:09 UTC


README

Build Status License

Bluphant is a PHP library to interact with Bluzelle Blockchain Database.

Bluzelle is a Blockchain Database that works in a system of swarms, this makes the availability, integrity, integrability and the consistency be natural. This is a PHP Database Adapter for Bluzelle.

There is a sample here that is the existent example in this package built with docker-compose:

Sample

Usage

Before everything, Bluphant is an Adapter, and to use it you just have to place it as an $adapter for you Database Layer.

It might be interesting to build other 2 classes to work with this:

  • Data Mapper

    $userMapper = new UserMapper($adapter);
  • Models

    $user = new User("Everchanging Joe", "joe@example.com");
    $userMapper->insert($user);

How to

Installation

Using Composer

composer require bluzelle/bluzelle-php

Because of the necessary support to protobuf, a required step to use this library is to install a PECL package through this command:

sudo pecl install protobuf-3.5.1

Prepare Adapter

use Bluphant\BluphantAdapter;

$adapter = new BluphantAdapter('127.0.0.1', 8100);

$table = '3f966cd1-ef79-4464-b3be-81e84002550b';

Statements

Create

$adapter->insert($table, [
    "key" => "key1",
    "value" => "sample value"
]);

Read

$adapter->select($table, [
    "key" => "key1"
]);

Update

$adapter->update($table, [
    "key" => "key1",
    "value" => "sample value 2"
]);

Delete

$adapter->delete($table, [
    "key" => "key1"
]);

Keys

$adapter->keys($table);

Execute

echo $adapter->execute();

Reference

Protobuf

There is a build step of this library for protobuf. This will be required so it accomplished the goal of Bluzelle project, which is to have a better environment for development and business.

During the build step, that is not required for someone that is simply using this library, is to run this at the root directory of this library:

protoc --proto_path=src/Datastructure --php_out=./src/Datastructure Database.proto