PHPackages                             sitmpcz/jsonrpc2 - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. sitmpcz/jsonrpc2

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

sitmpcz/jsonrpc2
================

jsonrpc2 implementation for generic use. Test suite for Nette Framework included.

v1.3.0(2y ago)034↓33.3%New BSDPHPPHP &gt;=5.3.2

Since Nov 1Pushed 8mo agoCompare

[ Source](https://github.com/sitmpcz/JSONRpc2)[ Packagist](https://packagist.org/packages/sitmpcz/jsonrpc2)[ Docs](http://github.com/foglcz/JSONRpc2)[ RSS](/packages/sitmpcz-jsonrpc2/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

JSON-RPC client and server libraries
====================================

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

This library contains a PHP implementation of JSON-RPC version 2, both client and server.

Installation
------------

[](#installation)

Download the contents of the `lib` folder to your project. Then simply include the library:

```
include "lib/Server.php";

```

### Server methods

[](#server-methods)

```
$server = new Lightbulb\Json\Rpc2\Server;

// Class based where all the methods in myClass are exposed as user.method
$server->user = new MyClass;

// Anything that is "callable", either built in PHP functions or your own
$server->upper     = 'strtoupper';
$server->userClean = 'userClean';

// Anonymous functions work too
$server->firstTwo = function($str) { return substr($str,0,2); };

// Force a namespace to map to an object method
$server->{'mytesthandler.myfunc'} = array($myObject, 'myMethod');

// Static method calls work
$server->myStaticHandler = 'MyStaticClass::theStaticFunction';

```

The methods, which are given to the server, can be then called via numbered or named parameters (see json-rpc specification here:  )

The server class respects binding of event methods:

```
// Bind events
$server->onBeforeCall[] = function($server) {};
$server->onBeforeCall[] = function($server) {};
$server->onSuccess[]    = function($server) {};
$server->onError[]      = function($server) {};

```

For detailed usage see comments with the server and clients class. For detailed tests see tests folder.

### Client calls

[](#client-calls)

```
$client = new Lightbulb\Json\Rpc2\Client('http://api.domain.com/endpoint');
$client->upper("kitten");
$client->firstTwo("Hello");

```

#### Client supports class chaining to call nested methods

[](#client-supports-class-chaining-to-call-nested-methods)

```
$ok = $client->user->login($user, $pass);

```

will actually result in following json call:

```
{... method: "user.login" ...}

```

License
-------

[](#license)

Licensed under the New BSD License. Copyright 2011 Pavel Ptacek. All rights reserved.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance43

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

929d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f61433f4e90accc109144c047dcad6df0e5425cd5980d08fe8d5e7cd7c64f1e?d=identicon)[dusanhomola](/maintainers/dusanhomola)

---

Top Contributors

[![scottchiefbaker](https://avatars.githubusercontent.com/u/3429760?v=4)](https://github.com/scottchiefbaker "scottchiefbaker (16 commits)")[![foglcz](https://avatars.githubusercontent.com/u/767839?v=4)](https://github.com/foglcz "foglcz (11 commits)")[![zabous](https://avatars.githubusercontent.com/u/8329461?v=4)](https://github.com/zabous "zabous (6 commits)")[![theo1024](https://avatars.githubusercontent.com/u/15445792?v=4)](https://github.com/theo1024 "theo1024 (2 commits)")[![b7kich](https://avatars.githubusercontent.com/u/572097?v=4)](https://github.com/b7kich "b7kich (1 commits)")

---

Tags

jsonnetterpc

### Embed Badge

![Health badge](/badges/sitmpcz-jsonrpc2/health.svg)

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

###  Alternatives

[datto/json-rpc

Fully unit-tested JSON-RPC 2.0 for PHP

1951.3M14](/packages/datto-json-rpc)[foglcz/jsonrpc2

jsonrpc2 implementation for generic use. Test suite for Nette Framework included.

1962.1k](/packages/foglcz-jsonrpc2)[weberhofer/jsonrpcphp

JSON-RPC for PHP 5.3+

22281.4k2](/packages/weberhofer-jsonrpcphp)[wa72/jsonrpc-bundle

JSON-RPC server for Symfony: exposes services registered in the service container as JSON-RPC webservices

3164.1k](/packages/wa72-jsonrpc-bundle)[cranetm/yii2-json-rpc-2.0

JSON RPC 2.0 for Yii2 strict type validation of request and response data

2679.6k1](/packages/cranetm-yii2-json-rpc-20)[nizsheanez/yii2-json-rpc

A lightweight JsonRpc Server and Client for PHP

2034.0k](/packages/nizsheanez-yii2-json-rpc)

PHPackages © 2026

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