Hive Developers logo

Hive Developer Portal

Getting Started

Before interact with the blockchain, we start with the presentation and configuration of relevant libraries.

Introduction

hive-php-lib try to be the most easier and powerful PHP library to interact with HIVE blockchain. This is a good choice for all PHP devs:


Installation

Do you know Composer? It’s the PHP package manager and hive-php-lib use it to be installed. It’s really easy to use, and the installation is available on the Composer download page.

When you are ready with that, just install the lib:

php composer.phar require hive/hive-php-lib

Composer will download and install the library for you.


Preparation

Include autoloader

In your PHP file, just add the autoload file:

require __DIR__ . '/vendor/autoload.php';

!!! Don’t forget to adapt the path !!!

Load the needed class

For production use with Hive, we recommend to use the Condenser class :

use Hive\PhpLib\Hive\Condenser as HiveCondenser;

Create configuration array

hive-php-lib need a small configuration array with 4 items :

here is an example :

$config = [
    "debug" => false,
    "disableSsl" => false,
    "heNode" => "api.hive-engine.com/rpc",
    "hiveNode" =>"anyx.io",
];

Usage

Now you just need to instantiate the HiveCondenser object, and you are ready to use any functions of it. Example:

$hiveApi = new HiveCondenser($config);
$result = $hiveApi->findProposal(211); // Will return data about the proposal 211

Conclusion

Pretty easy, isn’t it? In next tutorials, We will see how to interact directly with HIVE blockchain to retrieve data and how to use most of the functions in this lib.