edgetelemetrics / php-json-rpc
JSON-RPC helper classes for PHP
Installs: 3 436
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|>=8.0
- ext-json: *
Requires (Dev)
- clue/ndjson-react: ^1.2
- evenement/evenement: ^3.0.1
Suggests
- clue/ndjson-react: Used by the React Stream Decoder to process NDJSON input
- evenement/evenement: Used by the React Stream Decoder to emit events
README
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.
https://www.jsonrpc.org/specification
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