PHP code example of c3systems / c3-sdk-php

1. Go to this page and download the library: Download c3systems/c3-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

c3systems / c3-sdk-php example snippets



use SDK\Client;
use SDK\Util;

class App {
  public $client;

  function __construct() {
    $this->client = new Client;
  }

  function setItem($key, $value) {
    $this->client->state()->set(Util::string2ByteArray($key), Util::string2ByteArray($value));
  }

  function getItem($key) {
    $result = $this->client->state()->get(Util::string2ByteArray($key));
    return Util::byteArray2String($result->value);
  }
}

$app = new App;
$app->client->registerMethod('setItem', ['string', 'string'], array($app, 'setItem'));
$app->client->registerMethod('getItem', ['string'], array($app, 'getItem'));
$app->client->serve();
bash
composer