PHPackages                             fguillot/json-rpc - 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. fguillot/json-rpc

ActiveLibrary[API Development](/categories/api)

fguillot/json-rpc
=================

Simple JSON-RPC client/server library that just works

v1.5.0(3w ago)25768.7k↓40.1%18[2 issues](https://github.com/matasarei/json-rpc/issues)[1 PRs](https://github.com/matasarei/json-rpc/pulls)19MITPHPPHP &gt;=8.0CI passing

Since Nov 22Pushed 5mo ago3 watchersCompare

[ Source](https://github.com/matasarei/json-rpc)[ Packagist](https://packagist.org/packages/fguillot/json-rpc)[ Docs](https://github.com/matasarei/json-rpc)[ RSS](/packages/fguillot-json-rpc/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (9)Dependencies (6)Versions (29)Used By (19)

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

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

[![CI workflow](https://github.com/matasarei/json-rpc/actions/workflows/main.yml/badge.svg)](https://github.com/matasarei/json-rpc/actions/workflows/main.yml)[![Latest Stable Version](https://camo.githubusercontent.com/1b0de0adf416e469bf37d13b990a35a49119f59e004982d9361c0ef7b170ba11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666775696c6c6f742f6a736f6e2d7270632e737667)](https://packagist.org/packages/fguillot/json-rpc)[![Total Downloads](https://camo.githubusercontent.com/b56a0ca6aae0f59e162a6f88978dee763c051f838e634613468de0b48aefcea3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666775696c6c6f742f6a736f6e2d7270632e737667)](https://packagist.org/packages/fguillot/json-rpc)[![PHP Version](https://camo.githubusercontent.com/f62ef68ac108a1069aeb45e91104335b8840c35956aa33e55f44a0ae1321fc84/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f666775696c6c6f742f6a736f6e2d7270632e737667)](https://packagist.org/packages/fguillot/json-rpc)[![License](https://camo.githubusercontent.com/bb82b49d4088751bb0ae140645c91219f8f61b34cc1007fede8290da1ee4eba1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f666775696c6c6f742f6a736f6e2d7270632e737667)](LICENSE)

A simple JSON-RPC client/server that just works.

Project status
--------------

[](#project-status)

This repository is the maintained continuation of the original [fguillot/JsonRPC](https://packagist.org/packages/fguillot/json-rpc) library, which was abandoned and removed from GitHub by its original author. The package keeps its original name `fguillot/json-rpc` on Packagist so existing installations keep working; this repository (`matasarei/json-rpc`) is the canonical source. The library is in maintenance mode: it receives bug fixes, security fixes and compatibility updates for new PHP versions.

Features
--------

[](#features)

- JSON-RPC 2.0 only
- Client and server for batch requests and notifications
- HTTP Basic authentication and IP-based client restrictions
- Custom middleware
- PSR-3 logging of requests and responses (with credential redaction)
- No hard runtime dependency beyond `ext-json` and `psr/log`
- Works with the `curl` extension or, as a fallback, plain PHP streams
- Fully unit tested, statically analysed (PHPStan) and PSR-12 compliant
- Requires PHP 8.0+
- License: MIT

Contributors
------------

[](#contributors)

[Frédéric Guillot](https://github.com/fguillot) and many others:

[![Contributors](https://camo.githubusercontent.com/0e806b049b898b0a1d7c82fb15443b4d73803a7b910d6df22b52fd6f6c2622b7/68747470733a2f2f636f6e747269622e726f636b732f696d6167653f7265706f3d6d61746173617265692f6a736f6e2d727063)](https://camo.githubusercontent.com/0e806b049b898b0a1d7c82fb15443b4d73803a7b910d6df22b52fd6f6c2622b7/68747470733a2f2f636f6e747269622e726f636b732f696d6167653f7265706f3d6d61746173617265692f6a736f6e2d727063)

Requirements
------------

[](#requirements)

- PHP 8.0 or later
- `ext-json`
- `ext-curl` is optional; when it is not available the client transparently falls back to PHP streams

Installation with Composer
--------------------------

[](#installation-with-composer)

```
composer require fguillot/json-rpc
```

Examples
--------

[](#examples)

- [Server](#server)
- [Client](#client)
- [Client batch requests](#client-batch-requests)
- [Client notifications](#client-notifications)
- [Client exceptions](#client-exceptions)
- [Client logging and debugging](#client-logging-and-debugging)
- [IP based client restrictions](#ip-based-client-restrictions)
- [HTTP Basic Authentication](#http-basic-authentication)
- [Local Exceptions](#local-exceptions)
- [Production hardening](#production-hardening)
- [Callback before client request](#callback-before-client-request)

### Symfony

[](#symfony)

-

### Server

[](#server)

Callback binding:

```
