PHPackages                             mul53/blzphp - 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. mul53/blzphp

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

mul53/blzphp
============

Php library that can be used to access the Bluzelle database service.

v0.0.12(5y ago)047MITPHPPHP ~7.2

Since May 17Pushed 5y ago1 watchersCompare

[ Source](https://github.com/mul53/blzphp)[ Packagist](https://packagist.org/packages/mul53/blzphp)[ Docs](https://github.com/bluzelle/blzphp)[ RSS](/packages/mul53-blzphp/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (7)Versions (21)Used By (0)

blzphp
======

[](#blzphp)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f70f2aae9836a425c35dcbae1f9b74773a8fd690f25a8c329cb4cd6f3f7e7f83/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626c757a656c6c652f626c7a7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bluzelle/blzphp)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/b1c5423e3e4fb7ff7412075797a5501d24b8e67713f4c1c2487a964d40510821/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f626c757a656c6c652f626c7a7068702f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/bluzelle/blzphp)[![Coverage Status](https://camo.githubusercontent.com/1eab83cf13e8d8cea86cd359d50d0af11b22e003cade60aba52530096bc0fe59/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f626c757a656c6c652f626c7a7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bluzelle/blzphp/code-structure)[![Quality Score](https://camo.githubusercontent.com/63b101268ee3d652946a9804b88130ab9b64e93b7727695238245a5ec998171e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f626c757a656c6c652f626c7a7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bluzelle/blzphp)[![Total Downloads](https://camo.githubusercontent.com/681a8be816de7350b6710bf3f6cdc93df2cd59f84343cad0689af90c5a885861/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626c757a656c6c652f626c7a7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bluzelle/blzphp)

Installation
============

[](#installation)

You can install this library via Composer: composer require bluzelle/blzphp

Getting Started
===============

[](#getting-started)

In general, you must initialize blzphp before calling any other functions. Do the following using your own configuration parameters as applicable to initialize:

```
blz = new Bluzelle\Client('account', 'mnemonic', 'endpoint', 'chainId', 'uuid');
```

This performs some initial checks, retrieves your account information, and returns an object through which you can call the rest of the API functions.

You may now use the functions described below to perform database operations, as well as retrieve account and status information.

blzphp API documentation
========================

[](#blzphp-api-documentation)

Read below for detailed documentation on how to use the Bluzelle database service.

### new Bluzelle\\Client({...})

[](#new-bluzelleclient)

Configures the Bluzelle connection. Multiple clients can be created by creating new instances of this class.

```
use Bluzelle\Client;

api = new Client(
    'bluzelle1xhz23a58mku7ch3hx8f9hrx6he6gyujq57y3kp',
    'volcano arrest ceiling physical concert sunset absent hungry tobacco canal census era pretty car code crunch inside behind afraid express giraffe reflect stadium luxury',
    "http://localhost:1317",
    "20fc19d4-7c9d-4b5c-9578-8cedd756e0ea",
    "bluzelleTestPublic-1"
);
```

ArgumentDescription**address**The address of your Bluzelle account**mnemonic**The mnemonic of the private key for your Bluzelle accountendpoint(Optional) The hostname and port of your rest server. Default: uuid(Optional) Bluzelle uses `UUID`'s to identify distinct databases on a single swarm. We recommend using [Version 4 of the universally unique identifier](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_%28random%29). Defaults to the account address.chain\_id(Optional) The chain id of your Bluzelle account. Default: bluzelleThe calls below are methods of the instance created by instantiating the `Bluzelle::Swarm::Client` class.

General Functions
-----------------

[](#general-functions)

### version()

[](#version)

Retrieve the version of the Bluzelle service.

```
api->version();
```

Returns a promise resolving to a string containing the version information, e.g.

```
0.0.0-39-g8895e3e

```

Throws an exception if a response is not received from the connection.

### account()

[](#account)

Retrieve information about the currently active Bluzelle account.

```
api->account();
```

Returns a promise resolving to a JSON object representing the account information, e.g.

Throws an exception if a response is not received from the connection.

Database Functions
------------------

[](#database-functions)

### create($key, $value ,$gas\_info\[, $lease\_info\])

[](#createkey-value-gas_info--lease_info)

Create a field in the database.

```
api->create('mykey', '{ a: 13 }', ['gax_fee' => '400001'], ['days' => 100]);
```

ArgumentDescriptionkeyThe name of the key to createvalueThe string value to set the keygas\_infoObject containing gas parameters (see above)lease\_info (optional)Minimum time for key to remain in database (see above)Returns a promise resolving to nothing.

Throws an exception when a response is not received from the connection, the key already exists, or invalid value.

### read($key, $prove)

[](#readkey-prove)

Retrieve the value of a key without consensus verification. Can optionally require the result to have a cryptographic proof (slower).

```
value = api->read('mykey');
```

ArgumentDescriptionkeyThe key to retrieveproveA proof of the value is required from the network (requires 'config trust-node false' to be set)Returns a promise resolving the string value of the key.

Throws an exception when the key does not exist in the database. Throws an exception when the prove is true and the result fails verification.

### txRead($key, $gas\_info)

[](#txreadkey-gas_info)

Retrieve the value of a key via a transaction (i.e. uses consensus).

```
value = api->txRead('mykey', ['max_fee' => '400001']);
```

ArgumentDescriptionkeyThe key to retrievegas\_infoObject containing gas parameters (see above)Returns a promise resolving the string value of the key.

Throws an exception when the key does not exist in the database.

### update($key, $value , gas\_info, lease\_info)

[](#updatekey-value--gas_info-lease_info)

Update a field in the database.

```
api->update('mykey', '{ a: 13 }', ['max_fee': '400001'], ['days' => 100]);
```

ArgumentDescriptionkeyThe name of the key to createvalueThe string value to set the keygas\_infoObject containing gas parameters (see above)lease\_info (optional)Positive or negative amount of time to alter the lease by. If not specified, the existing lease will not be changed.Returns a promise resolving to nothing.

Throws an exception when the key doesn't exist, or invalid value.

### delete($key, $gas\_info)

[](#deletekey-gas_info)

Delete a field from the database.

```
api->delete('mykey', ['max_fee' => '400001']);
```

ArgumentDescriptionkeyThe name of the key to deletegas\_infoObject containing gas parameters (see above)Returns a promise resolving to nothing.

Throws an exception when the key is not in the database.

### has($key)

[](#haskey)

Query to see if a key is in the database. This function bypasses the consensus and cryptography mechanisms in favor of speed.

```
hasMyKey = api->has('mykey');
```

ArgumentDescriptionkeyThe name of the key to queryReturns a promise resolving to a boolean value - `true` or `false`, representing whether the key is in the database.

### txHas($key, $gas\_info)

[](#txhaskey-gas_info)

Query to see if a key is in the database via a transaction (i.e. uses consensus).

```
hasMyKey = api->txHas('mykey', ['gas_price' => 10]);
```

ArgumentDescriptionkeyThe name of the key to querygas\_infoObject containing gas parameters (see above)Returns a promise resolving to a boolean value - `true` or `false`, representing whether the key is in the database.

### keys()

[](#keys)

Retrieve a list of all keys. This function bypasses the consensus and cryptography mechanisms in favor of speed.

```
keys = api->keys();
```

Returns a promise resolving to an array of strings. ex. `["key1", "key2", ...]`.

### txKeys($gas\_info)

[](#txkeysgas_info)

Retrieve a list of all keys via a transaction (i.e. uses consensus).

```
keys = api->txKeys([ 'gas_price' => 10]);
```

ArgumentDescriptiongas\_infoObject containing gas parameters (see above)Returns a promise resolving to an array of strings. ex. `["key1", "key2", ...]`.

### rename($key, $new\_key, $gas\_info)

[](#renamekey-new_key-gas_info)

Change the name of an existing key.

```
api->rename('key', 'newkey', ['gas_price' => 10]);
```

ArgumentDescriptionkeyThe name of the key to renamenew\_keyThe new name for the keygas\_infoObject containing gas parameters (see above)Returns a promise resolving to nothing.

Throws an exception if the key doesn't exist.

ArgumentDescriptionkeyThe name of the key to queryReturns a promise resolving to a boolean value - `true` or `false`, representing whether the key is in the database.

### count()

[](#count)

Retrieve the number of keys in the current database/uuid. This function bypasses the consensus and cryptography mechanisms in favor of speed.

```
number = api->count();
```

Returns a promise resolving to an integer value.

### txCount($gas\_info)

[](#txcountgas_info)

Retrieve the number of keys in the current database/uuid via a transaction.

```
number = api->txCount(['gas_price' => 10]);
```

ArgumentDescriptiongas\_infoObject containing gas parameters (see above)Returns a promise resolving to an integer value.

### deleteAll($gas\_info)

[](#deleteallgas_info)

Remove all keys in the current database/uuid.

```
api->deleteAll([gas_price => 10]);
```

ArgumentDescriptiongas\_infoObject containing gas parameters (see above)Returns a promise resolving to nothing.

### keyValues()

[](#keyvalues)

Enumerate all keys and values in the current database/uuid. This function bypasses the consensus and cryptography mechanisms in favor of speed.

```
kvs = api->keyValues();
```

Returns a promise resolving to a JSON array containing key/value pairs, e.g.

```
[{"key": "key1", "value": "value1"}, {"key": "key2", "value": "value2"}]

```

### txKeyValues($gas\_info)

[](#txkeyvaluesgas_info)

Enumerate all keys and values in the current database/uuid via a transaction.

```
kvs = api->txKeyValues(['gas_price' => 10]);
```

ArgumentDescriptiongas\_infoObject containing gas parameters (see above)Returns a promise resolving to a JSON array containing key/value pairs, e.g.

```
[{"key": "key1", "value": "value1"}, {"key": "key2", "value": "value2"}]

```

### multiUpdate($key\_values, $gas\_info)

[](#multiupdatekey_values-gas_info)

Update multiple fields in the database.

```
api->multiUpdate([['key' => "key1", 'value' => "value1"], ['key' => "key2", 'value' => "value2"], ['gas_price': 10]]);
```

ArgumentDescriptionkey\_valuesAn array of objects containing keys and values (see example avove)gas\_infoObject containing gas parameters (see above)Returns a promise resolving to nothing.

Throws an exception when any of the keys doesn't exist.

### getLease($key)

[](#getleasekey)

Retrieve the minimum time remaining on the lease for a key. This function bypasses the consensus and cryptography mechanisms in favor of speed.

```
value = api->getLease('mykey');
```

ArgumentDescriptionkeyThe key to retrieve the lease information forReturns a promise resolving the minimum length of time remaining for the key's lease, in seconds.

Throws an exception when the key does not exist in the database.

### txGetLease($key, $gas\_info)

[](#txgetleasekey-gas_info)

Retrieve the minimum time remaining on the lease for a key, using a transaction.

```
value = api->txGetLease('mykey', ['gas_price' => 10]);
```

ArgumentDescriptionkeyThe key to retrieve the lease information forgas\_infoObject containing gas parameters (see above)Returns a promise resolving the minimum length of time remaining for the key's lease, in seconds.

Throws an exception when the key does not exist in the database.

### renew\_lease($key, $gas\_info, $lease\_info)

[](#renew_leasekey-gas_info-lease_info)

Update the minimum time remaining on the lease for a key.

```
value = api->renewLease('mykey', ['max_fee' => '400001'], [ 'days' => 100 ]);
```

ArgumentDescriptionkeyThe key to retrieve the lease information forgas\_infoObject containing gas parameters (see above)lease\_info (optional)Minimum time for key to remain in database (see above)Returns a promise resolving the minimum length of time remaining for the key's lease.

Throws an exception when the key does not exist in the database.

### renewLeaseAll($gas\_info, $lease\_info)

[](#renewleaseallgas_info-lease_info)

Update the minimum time remaining on the lease for all keys.

```
value = api->renewLeaseAll(['max_fee' => '400001'], [ 'days' => 100 ]);
```

ArgumentDescriptiongas\_infoObject containing gas parameters (see above)lease\_info (optional)Minimum time for key to remain in database (see above)Returns a promise resolving the minimum length of time remaining for the key's lease.

Throws an exception when the key does not exist in the database.

### getNShortestLease($n)

[](#getnshortestleasen)

Retrieve a list of the n keys in the database with the shortest leases. This function bypasses the consensus and cryptography mechanisms in favor of speed.

```
keys = api->getNShortestLease(10);
```

ArgumentDescriptionnThe number of keys to retrieve the lease information forReturns a JSON array of objects containing key, lease (in seconds), e.g.

```
[ { key: "mykey", lease: { seconds: "12345" } }, {...}, ...]

```

### txGetNShortestLease($n, $gas\_info)

[](#txgetnshortestleasen-gas_info)

Retrieve a list of the N keys/values in the database with the shortest leases, using a transaction.

```
keys = api.txGetNShortestLease(10, ['max_fee' => '400001']);
```

ArgumentDescriptionnThe number of keys to retrieve the lease information forgas\_infoObject containing gas parameters (see above)Returns a JSON array of objects containing key, lifetime (in seconds), e.g.

```
[ { key: "mykey", lifetime: "12345" }, {...}, ...]

```

Development
-----------

[](#development)

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [phpgems.org](https://phpgems.org).

Contributing
------------

[](#contributing)

Bug reports and pull requests are welcome on GitHub at . This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mul53/bluzelle/blob/master/CODE_OF_CONDUCT.md).

License
-------

[](#license)

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

Code of Conduct
---------------

[](#code-of-conduct)

Everyone interacting in the Bluzelle project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mul53/bluzelle/blob/master/CODE_OF_CONDUCT.md).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

12

Last Release

2162d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1048c046ebbd045386428b96c974a91d2f314c0c7c924c2c77601352ddcfff3a?d=identicon)[mul53](/maintainers/mul53)

---

Top Contributors

[![mul53](https://avatars.githubusercontent.com/u/19148531?v=4)](https://github.com/mul53 "mul53 (52 commits)")[![philsturgeon](https://avatars.githubusercontent.com/u/67381?v=4)](https://github.com/philsturgeon "philsturgeon (49 commits)")[![frankdejonge](https://avatars.githubusercontent.com/u/534693?v=4)](https://github.com/frankdejonge "frankdejonge (38 commits)")[![ravage84](https://avatars.githubusercontent.com/u/625761?v=4)](https://github.com/ravage84 "ravage84 (10 commits)")[![gmponos](https://avatars.githubusercontent.com/u/5675248?v=4)](https://github.com/gmponos "gmponos (10 commits)")[![jotaelesalinas](https://avatars.githubusercontent.com/u/2042875?v=4)](https://github.com/jotaelesalinas "jotaelesalinas (8 commits)")[![RobLoach](https://avatars.githubusercontent.com/u/25086?v=4)](https://github.com/RobLoach "RobLoach (7 commits)")[![colinodell](https://avatars.githubusercontent.com/u/202034?v=4)](https://github.com/colinodell "colinodell (7 commits)")[![hansott](https://avatars.githubusercontent.com/u/3886384?v=4)](https://github.com/hansott "hansott (7 commits)")[![browner12](https://avatars.githubusercontent.com/u/5232313?v=4)](https://github.com/browner12 "browner12 (5 commits)")[![reinink](https://avatars.githubusercontent.com/u/882133?v=4)](https://github.com/reinink "reinink (5 commits)")[![bcrowe](https://avatars.githubusercontent.com/u/752603?v=4)](https://github.com/bcrowe "bcrowe (5 commits)")[![EmanueleMinotto](https://avatars.githubusercontent.com/u/417201?v=4)](https://github.com/EmanueleMinotto "EmanueleMinotto (5 commits)")[![marcqualie](https://avatars.githubusercontent.com/u/101022?v=4)](https://github.com/marcqualie "marcqualie (4 commits)")[![hassankhan](https://avatars.githubusercontent.com/u/1781985?v=4)](https://github.com/hassankhan "hassankhan (3 commits)")[![fulldecent](https://avatars.githubusercontent.com/u/382183?v=4)](https://github.com/fulldecent "fulldecent (3 commits)")[![jclyons52](https://avatars.githubusercontent.com/u/6395559?v=4)](https://github.com/jclyons52 "jclyons52 (3 commits)")[![alexbilbie](https://avatars.githubusercontent.com/u/77991?v=4)](https://github.com/alexbilbie "alexbilbie (2 commits)")[![assertchris](https://avatars.githubusercontent.com/u/200609?v=4)](https://github.com/assertchris "assertchris (2 commits)")[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (2 commits)")

---

Tags

bluzelleblzphp

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/mul53-blzphp/health.svg)

```
[![Health](https://phpackages.com/badges/mul53-blzphp/health.svg)](https://phpackages.com/packages/mul53-blzphp)
```

###  Alternatives

[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[tpetry/laravel-mysql-explain

Get Visual MySQL EXPLAIN for Laravel.

264154.2k](/packages/tpetry-laravel-mysql-explain)[aternus/geonames-client

GeoNames API Client

39215.5k2](/packages/aternus-geonames-client)[gearbox-solutions/eloquent-filemaker

A package for getting FileMaker records as Eloquent models in Laravel

6454.8k2](/packages/gearbox-solutions-eloquent-filemaker)[hardcastle/xrpl_php

PHP SDK / Client for the XRP Ledger

129.7k5](/packages/hardcastle-xrpl-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
