Download the PHP package onematrix/tracing-sdk without Composer

On this page you can find all versions of the php package onematrix/tracing-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package tracing-sdk

Tracing SDK (PHP)

PHP implementation of the Tracing SDK. Canonicalizes a record, hashes it with Keccak-256, and sends the hash to an Indexer service. Canonicalization and hashing happen inside send()/sendBatch(), which return the hash alongside the Indexer's response. The SDK has no buffering, timers, or background sending — you decide when to send, one record at a time or a batch. Once a record is anchored, it can be looked up again by its hash.

Requires PHP 7.1+ or 8.x, plus the json, dom, libxml, curl, and mbstring extensions.

Install

Usage

Choosing the data type

dataType decides how a record is canonicalized before hashing. It travels in a SendOptions object, which can be set as the config default, per call, or both:

A per-call SendOptions wins over the config one; when neither supplies a dataType, the call throws ConfigException. That makes options optional in the constructor — omit it if every call passes its own. Each sendBatch() call canonicalizes all of its records with one data type, so send mixed types as separate calls.

SendOptions is immutable: new SendOptions('json') and SendOptions::dataType('json') are equivalent, and withDataType() returns a modified copy rather than mutating the original.

send() returns ['hash' => …, 'response' => ['statusCode', 'body', 'recordCount']]. sendBatch() sends every record in a single request and returns one such entry per input record, in input order — each carries its own hash and shares the one response of that request.

send()/sendBatch() throw Tracing\Sdk\Exception\TransportException on a failed or rejected request — catch it, retry, queue, batch up before sending, or whatever else suits the caller. They throw Tracing\Sdk\Exception\ConfigException when signingTime is missing or a batch record lacks rawData/signingTime, and Tracing\Sdk\Exception\CanonicalizationException when rawData can't be canonicalized for the chosen dataType; both are raised before anything is sent.

Runnable examples

example/php/ holds complete, runnable scripts — the quickest way to see the whole flow end to end:

File What it shows
example/php/single-send-example.php Sending one JSON record with send()
example/php/example.php Sending several JSON records in one request with sendBatch()
example/php/xml-example.php The same batch flow with SendOptions::dataType('xml')
example/php/query-example.php Sending a record, then looking the anchor up with queryByHash()

Each script points at http://localhost:3000 with a placeholder API token — edit the endpoint and auth values at the top to match your Indexer, then run:

Querying an anchor by hash

queryByHash() resolves a record's hash to the blockchain transactions that anchored it, via GET {endpoint}/api/anchors?hash=<hash>. The hash is URL-encoded for you, and the configured auth is applied exactly as it is for sending.

Returns an array with exactly two keys:

Key Description
hash The record hash that was queried, as echoed back by the Indexer.
txHashes List of blockchain transactions the record was anchored in. The same record can be anchored more than once, so this is always a list — iterate it rather than assuming a single element.

It throws Tracing\Sdk\Exception\ConfigException when $hash is empty, and Tracing\Sdk\Exception\TransportException when the request fails, the Indexer answers with a non-2xx status (including the 404 you get for a hash that was never anchored), or the response body isn't a { hash, txHashes } object. A hash that hasn't been anchored yet is therefore an exception, not a null return — so a lookup that must tolerate "not there yet" belongs in a try/catch.

Hashing is deterministic, so the same record always yields the same hash — keep the hash returned by send()/sendBatch() and query it whenever you need to.

Auth options

Design notes

Testing


All versions of tracing-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1 || ^8.0
ext-json Version *
ext-dom Version *
ext-libxml Version *
ext-curl Version *
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package onematrix/tracing-sdk contains the following files

Loading the files please wait ...