lunanimous/php-rpc-client

This package is abandoned and no longer maintained. No replacement package was suggested.

Nimiq RPC Client for PHP

v1.1.0 2020-03-22 13:42 UTC

This package is auto-updated.

Last update: 2021-02-22 15:55:35 UTC


README

PHP implementation of the Nimiq RPC client specs.

About

Latest Stable Version continuous integration

A Nimiq RPC client library in PHP. This client library implements the Nimiq RPC specification.

Installation

The recommended way to install Nimiq PHP Client is with Composer. Composer is a dependency management tool for PHP that allows you to declare the dependencies your project needs and installs them into your project.

# Install Composer
curl -sS https://getcomposer.org/installer | php

You can add Nimiq PHP Client as a dependency using the composer.phar CLI:

php composer.phar require lunanimous/php-rpc-client

Alternatively, you can specify Guzzle as a dependency in your project's existing composer.json file:

{
    "require": {
        "lunanimous/php-rpc-client": "~1.0"
    }
}

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

You can find out more on how to install Composer, configure autoloading, and other best-practices for defining dependencies at getcomposer.org.

Usage

You can send requests with to a Nimiq node using a Lunanimous\Rpc\NimiqClient object.

$config = [
    'scheme' => 'http',
    'host' => '127.0.0.1',
    'port' => 8648,
    'user' => 'luna',
    'password' => 'moon',
    'timeout' => false,
];

$client = new \Lunanimous\Rpc\NimiqClient($config);

Once we have the client, we can start communicating with the Nimiq node. If no $config object is passed in constructor it will use same defaults as the Nimiq node defaults.

$client = new \Lunanimous\Rpc\NimiqClient();
$blockNumber = $client->getBlockNumber();

echo $blockNumber;

To discover all methods that are available head over to the documentation.

Documentation

The complete documentation is available in the /docs folder, you can also view it here.

You can also check out the Nimiq RPC specs which this client is compliant.

License

Apache 2.0