2017 © Pedro Peláez
 

library barrel-php

PHP client library for Barrel-DB, a document-oriented database.

image

barrel-db/barrel-php

PHP client library for Barrel-DB, a document-oriented database.

  • Tuesday, March 13, 2018
  • by tahteche
  • Repository
  • 2 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Barrel-php

PHP client for Barrel-DB, an open source document-oriented database focusing on data locality (put/match the data next to you) and P2P., (*1)

Visit https://barrel-db.org/ for installation intructions for Barrel-DB and to learn about the concepts that underpin Barrel-DB., (*2)

Installation

Install via composer:, (*3)

$ composer require barrel-db/barrel-php

Usage

Barrel-DB uses the JSON format but using this library spares you from converting your data to JSON by using associative arrays which are native to PHP. For example:, (*4)

The following doc:, (*5)

{
  "id" : "tahteche",
  "name" : "Teche Tah",
  "hobbies" : ["eat", "sleep", "code"]
}

Will be:, (*6)

[
  "id" => "tahteche",
  "name" => "Teche Tah",
  "hobbies" => ["eat", "sleep", "code"]
]

The example below assumes your Barrel-DB server is serving request at, http://localhost:7080/dbs/ and the database you are perfoming operations on is testdb. All the functions below operate on an instance of the Database class which has been instantiated with the server link and database name., (*7)

<?php

use Barrel\Database;

$server_url = 'http://localhost:7080/dbs';
$db_name = 'testdb';

=======================================================
Database Operations - Create, get, and delete databases
=======================================================

//Create instance of the Database class which you will use for request to create or use a Barrel databse.
$db = new Database($server_url, $db_name);

//Create 'testdb' database on you Barrel server
$res = $db->post();

//Get info about the 'testdb' database e.g number of documents
$res = $db->get();

//Get list of all databases available on your Barrel server
$res = $db->getAll();

//Delete 'testdb' database from Barrel
$res = $db->delete();

===============================================================
Document Operations - Create, read, update and delete documents
===============================================================

//Create a document in the 'testdb' database
$res = $db->postDoc($doc);

//Read a document from the 'testdb' database
$res = $db->getDoc($doc_id);

//Read ALL documents from the 'testdb' database
$res = $db->postAllDocs();

//Update a document in the 'testdb' database
$res = $db->putDoc($doc);

//Delete a document from the 'testdb' database
$res = $db->deleteDoc($doc_id);

Submitting bugs and feature requests

Bugs and feature request are tracked via GitHub issues., (*8)

Author

Tah Teche - https://twitter.com/tahteche, (*9)

License

Barrel-php is licensed under the Apache-2.0 License - see the LICENSE file for details, (*10)

The Versions

13/03 2018

dev-master

9999999-dev

PHP client library for Barrel-DB, a document-oriented database.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Tah Teche