PHP

You are here:
< Back

PHP Installation

Documentation can be found here.

Others solutions like LAMPWAMP or MAMP are available

Installation

$ composer require qredit/client

Development setup

If you want to contribute to the code of this package execute the following commands

  1. Fork the package
  2. Clone your forked repository
$ git clone https://github.com/<githubusername>/php-client
  1. Next, move into the fresh cloned directory
$ cd php-client
  1. Install the dependencies with composer
$ composer install
  1. Dependencies are now installed, you can now run the tests to see if everything is running like it should
$ phpunit tests/
...

Usage

Connections

<?php

require_once('vendor/autoload.php');

use Qredit\Client\Connection;
use Qredit\Client\ConnectionManager;

$manager = new ConnectionManager();

$manager->connect([
    'host' => 'http://my-main.qredit.node:port/api/', // TRAILING SLASH!
], 'main');

$manager->connect([
    'host' => 'http://my-backup.qredit.node:port/api/', // TRAILING SLASH!
], 'backup');

$response = [];

try {
    $response = $manager->connection('main')->wallets()->show('DARiJqhogp2Lu6bxufUFQQMuMyZbxjCydN');
} catch (Exception $e) {
    $response = $manager->connection('backup')->wallets()->show('DARiJqhogp2Lu6bxufUFQQMuMyZbxjCydN');
}

if ($response['data']) {
    echo($response['data']);
} else {
    echo('Both the main and backup node did not repsond.');
}

Initialiation

<?php

require_once('vendor/autoload.php');

use Qredit\Client\Connection;

$connection = new Connection([
    'host' => 'http://my.qredit.node:port/api/', // TRAILING SLASH!
]);
...

Blocks

<?php
...
$response = $connection->blocks()->all(['limit' => 10]);

if ($response['data']) {
    echo($response['data']);
}

>> ['meta': ['count': 10, ... ]]

Delegates

...
$response = $connection->delegates()->all(['limit' => 10]);

if ($response['data']) {
    echo($response['data']);
}

>> ['meta': ['count': 10, ... ]]

Node

...
$response = $connection->node()-status();

if ($response['data']) {
    echo($response['data']);
}

>> ['data': ['syncing': False, 'blocks': -22, 'height': 820355, 'id': '2134055295567604949']]

Peers

...
$response = $connection->peers()->all(['limit' => 10]);

if ($response['data']) {
    echo($response['data']);
}

>> ['meta': ['count': 10, ... ]]

Transactions

...
$response = $connection->transactions()->all(['limit' => 10]);

if ($response['data']) {
    echo($response['data']);
}

>> ['meta': ['count': 10, ... ]]

Votes

...
$response = $connection->votes()->all(['limit' => 10]);

if ($response['data']) {
    echo($response['data']);
}

>> ['meta': ['count': 10, ... ]]

Wallets

...
$response = $connection->wallets()->all(['limit' => 10]);

if ($response['data']) {
    echo($response['data']);
}

>> ['meta': ['count': 10, ... ]]
Last Updated On January 15, 2019