PHPackages                             barrel-db/barrel-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. barrel-db/barrel-php

ActiveLibrary[Database &amp; ORM](/categories/database)

barrel-db/barrel-php
====================

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

161PHP

Since Mar 13Pushed 8y ago2 watchersCompare

[ Source](https://github.com/barrel-db/barrel-php)[ Packagist](https://packagist.org/packages/barrel-db/barrel-php)[ RSS](/packages/barrel-db-barrel-php/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Barrel-php
==========

[](#barrel-php)

PHP client for [Barrel-DB](https://barrel-db.org/), an open source document-oriented database focusing on data locality (put/match the data next to you) and P2P.

Visit  for installation intructions for Barrel-DB and to learn about the concepts that underpin Barrel-DB.

Installation
------------

[](#installation)

Install via composer:

```
$ composer require barrel-db/barrel-php

```

Usage
-----

[](#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:

The following doc:

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

Will be:

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

The example below assumes your Barrel-DB server is serving request at,  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.

```
