PHPackages                             rc/jsonrpc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rc/jsonrpc

ActiveLibrary[API Development](/categories/api)

rc/jsonrpc
==========

Library for Json RPC 2.0 Specification

09PHP

Since Aug 29Pushed 9y ago1 watchersCompare

[ Source](https://github.com/rafaelcalleja/jsonrpc-spec)[ Packagist](https://packagist.org/packages/rc/jsonrpc)[ RSS](/packages/rc-jsonrpc/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP JSON-RPC 2.0 Specification
==============================

[](#php-json-rpc-20-specification)

[![Build Status](https://camo.githubusercontent.com/2f58ed73728ad08055fc51d5b3c2e6616ac965a6428e68c7748ec634335eb753/68747470733a2f2f7472617669732d63692e6f72672f72616661656c63616c6c656a612f6a736f6e7270632d737065632e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rafaelcalleja/jsonrpc-spec)

Request Object
--------------

[](#request-object)

```
use JsonRPC\Request\Method;
use JsonRPC\Request\Param;
use JsonRPC\Request\Request;
use JsonRPC\Request\RequestId;

$request = new Request(
      new Method('subtract'),
      new Param(array(42, 23)),
      new RequestId(1)
  );

echo json_encode($request);

{"jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": 1}
```

Notification Object
-------------------

[](#notification-object)

```
use JsonRPC\Request\Method;
use JsonRPC\Request\Param;
use JsonRPC\Request\Notification;

$request = new Notification(
        new Method('update'),
        new Param(array(1, 2, 3, 4, 5))
    );

echo json_encode($request);

{"jsonrpc": "2.0", "method": "update", "params": [1,2,3,4,5]}
```

Batch Request
-------------

[](#batch-request)

```
use JsonRPC\Request\Method;
use JsonRPC\Request\Param;
use JsonRPC\Request\Notification;
use JsonRPC\Request\Request;
use JsonRPC\Request\RequestId;

$request = array(
            new Request(
                new Method('sum'),
                new Param(array(1, 2, 4)),
                new RequestId('1')
            ),
            new Notification(
                new Method('notify_hello'),
                new Param(array(7))
            )
      );

echo json_encode($request);

[
  {"jsonrpc": "2.0", "method": "sum", "params": [1,2,4], "id": "1"},
  {"jsonrpc": "2.0", "method": "notify_hello", "params": [7]},
]
```

Response Object
---------------

[](#response-object)

```
use JsonRPC\Response\Response;
use JsonRPC\Response\Success;

$response = new Response('{"jsonrpc": "2.0", "method": "subtract", "params": [23, 42], "id": 2}');
$request = $response->request();

//... call_user_func_array($request->method()->name(), $request->params()->params());

$result = new Success(-19);
$response = $response->handleResult($result);

echo json_encode($response);

{"jsonrpc": "2.0", "result": -19, "id": 2}
```

Batch Response
--------------

[](#batch-response)

```
use JsonRPC\Exception\MethodNotFoundException;
use JsonRPC\Response\Error;
use JsonRPC\Response\Response;
use JsonRPC\Response\Success;
use JsonRPC\Response\CodeId

$object = new Response('[
                                {"jsonrpc": "2.0", "method": "sum", "params": [1,2,4], "id": "1"},
                                {"jsonrpc": "2.0", "method": "subtract", "params": [42,23], "id": "2"}
                          ]');

foreach ($object as $response) {

  $request = $response->request();

  try
  {
      //... call_user_func_array($request->method()->name(), $request->params()->params());
      $result = new Success( array(1, 2, 4) );

  }catch(MethodNotFoundException $e){
      $result = new Error(
                  new CodeId($e->getCode())
                  $e->getMessage()
        );
  }

  $object = $object->resolveResponse($result, $response);
}

echo json_encode($object);

[
  {"jsonrpc": "2.0", "result": 7, "id": "1"},
  {"jsonrpc": "2.0", "error": {"code": -32601, "message": "Method not found"}, "id": "2"},
]
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6dda251956e0fe106611712706d7f85f8c08ab972dc044b98cb56c8baa6f6dbd?d=identicon)[rafaelcalleja](/maintainers/rafaelcalleja)

---

Top Contributors

[![rafaelcalleja](https://avatars.githubusercontent.com/u/3765194?v=4)](https://github.com/rafaelcalleja "rafaelcalleja (5 commits)")

### Embed Badge

![Health badge](/badges/rc-jsonrpc/health.svg)

```
[![Health](https://phpackages.com/badges/rc-jsonrpc/health.svg)](https://phpackages.com/packages/rc-jsonrpc)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
