Skip to content

lucasnetau/php-json-rpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

JSON RPC Helper Libraries for PHP

This library contains classes to construct JSON RPC notification, request, response and error objects.

Additionally there is a ReactPHP stream decoder included which will process JSON RPC request and responses encoded via NDJSON.

Quickstart

Create a Request on the client

<?php
use EdgeTelemetrics\JSON_RPC\Request;
$request = new Request('ping', [], 'requestId');

$packet = json_encode($request);

// Send $packet to Server

Server side

<?php
//Process request

// Create the response from the request to pre-fill ID
$response = new Response::createFromRequest($request);
$response->setResult('pong');

$packet = json_encode($response);

// Send $packet back to Client