PHPackages                             wwtg99/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. wwtg99/jsonrpc

ActiveLibrary[API Development](/categories/api)

wwtg99/jsonrpc
==============

0.2.2(8y ago)37.4k1PHP

Since Apr 14Pushed 8y ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (6)Used By (0)

JSON-RPC Server and Client
==========================

[](#json-rpc-server-and-client)

JSON-RPC 2.0 server and client, implementation of [JSON-RPC 2.0](http://www.jsonrpc.org/) for Laravel.

Features
========

[](#features)

- JSON-RPC 2.0 only
- Support batch requests and notifications
- Simple to use for Laravel
- Require PHP &gt;= 5.6 and GuzzleHttp &gt;= 6.0
- License: MIT

JSON-RPC specification
======================

[](#json-rpc-specification)

- [English](http://www.jsonrpc.org/specification)
- [中文版](http://wiki.geekdream.com/Specification/json-rpc_2.0.html)

Installation
============

[](#installation)

```
composer require wwtg99/jsonrpc

```

For Lumen or earlier Laravel than v5.5, you need to register the service provider and alias manually,

```
Wwtg99\JsonRpc\Provider\JsonRpcServiceProvider::class
```

```
'JsonRpc' => Wwtg99\JsonRpc\Facades\JsonRpc::class
```

Usage
=====

[](#usage)

Server Side
-----------

[](#server-side)

### Bind Methods

[](#bind-methods)

Bind callback:

```
JsonRpc::bind('method1', function($request) {
    $method = $request->getMethod();
    $params = $request->getParams();
    $p = $request->parseParam('name');  //get param name
    $id = $request->getId();

    //some process...

    //return result array, request id will be added automatically
    return [1, 2, 3];
    //Or use JsonRpcResponse
    return new JsonRpcResponse($id, [1, 2, 3]);
    //return error
    return new JsonRpcResponse($id, null, ['code'=>1, 'message'=>'error']);
});

// Or use handler instance
$ph = resolve('ProcessHandler');
$ph->bind('method1', function($request) {
    return [1, 2, 3];
});
```

Bind class method

```
namespace Test;
class BindingTest {
    public function test1($request)
    {
        return [1, 2, 3];
    }
}
JsonRpc::bind('method2', 'Test\BindingTest@test1');
// Or $ph->bind('method2', 'Test\BindingTest@test1');
```

### Handle requests

[](#handle-requests)

Add route

```
//you should disable VerifyCsrfToken middleware if use post method
Route::match(['GET', 'POST'], '/json_rpc', function() {
    $res = JsonRpc::parse(request());
    //other process
    return response()->json($res);
});
```

Or simply use

```
Route::match(['GET', 'POST'], '/json_rpc', function (\Illuminate\Http\Request $request) {
    return Wwtg99\JsonRpc\Provider\JsonRpcRouter::parse($request);
});
```

Client Side
-----------

[](#client-side)

### Send request in client

[](#send-request-in-client)

The first parameter is json rpc server url, and second parameter is config options.

#### Options

[](#options)

- http\_method: http method to send request, get or post, default post
- return\_type: return type for response, json or string, default json

Other options will be sent to [Guzzle client](http://docs.guzzlephp.org/en/stable/request-options.html).

```
//get client
$cli = new JsonRpcClient($url);  //default method is post, return type json
//use get method
//$cli = new JsonRpcClient($url, ['http_method'=>'get']);
//use raw string return instead of json
//$cli = new JsonRpcClient($url, ['return_type'=>'string']);

//build requests
$req1 = new JsonRpcRequest('method1', 1, [1, 2, 3]);
$req1 = new JsonRpcRequest('method1', 2, [1, 2, 3]);

//send one request
$res = $cli->send($req1);
//send batch requests
$res = $cli->appendRequest($req1)->appendRequest($req2)->send();
//send notify
$cli->notify('method2', ['a'=>'b'])
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

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.

###  Release Activity

Cadence

Every ~59 days

Total

5

Last Release

3127d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b34e1979bed52d6644fa09df287ed7ced3fd21989c7ec02e722ae0c192cd89d4?d=identicon)[wwtg99](/maintainers/wwtg99)

---

Tags

json-rpclaravellaraveljsonrpc

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.5M923](/packages/statamic-cms)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[flat3/lodata

OData v4.01 Producer for Laravel

99346.1k](/packages/flat3-lodata)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)

PHPackages © 2026

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