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

ActiveLibrary[API Development](/categories/api)

timmachine/php-json-rpc
=======================

28PHP

Since Nov 26Pushed 11y ago1 watchersCompare

[ Source](https://github.com/Tim-Machine/PHP_Json_RPC_2.0)[ Packagist](https://packagist.org/packages/timmachine/php-json-rpc)[ RSS](/packages/timmachine-php-json-rpc/feed)WikiDiscussions dev Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/4b6b616c3f1479eb0eefb147335049480f06390af5a0a1cfae9c20e2c822ea12/68747470733a2f2f7472617669732d63692e6f72672f54696d2d4d616368696e652f5048505f4a736f6e5f5250435f322e302e7376673f6272616e63683d646576)](https://travis-ci.org/Tim-Machine/PHP_Json_RPC_2.0)

\##Router the router allows you to map a string to a method inside of the class. The @ symbol is used to separate the class from the method name. It really doesn't do much on its own, but is a requirement for the Listener

```
$router = new \Timmachine\PhpJsonRpc\Router();
$router->add("math.subtract", 'BaseController@subtract');
$router->add("math.add", 'BaseController@add');
```

Listener
--------

[](#listener)

The listener is the brains of the operation. This bad boy will take your Json request twist it around and execute the method you want to call and then return the data to you in a properly formatted JsonRPC 2.0 format

```
    $json = '{"jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": 1}';

    $listener = new \Timmachine\PhpJsonRpc\Listener($routes);

    try {

        //validate our json
        $listener->validateJson($json);

        // process the method request
        $listener->processRequest();

        // return our json response
        return $listener->getResponse();
    } catch (\Timmachine\PhpJsonRpc\RpcExceptions $e) {

        // even if there is an error you send a response back to your client that is properly formatted
        return $listener->getResponse();
    }
```

New JsonRPC versions?
---------------------

[](#new-jsonrpc-versions)

lets make sure that we are forward thinking a little

```
    $listener = new \Timmachine\PhpJsonRpc\Listener($routes,'2.1');
```

Custom Requirements ?
---------------------

[](#custom-requirements-)

Maybe your application has some custom requirements ?

```
$customRequirements = [
    [
        'key'          => 'myCustomKey',
        'value'        => null //no defined required value,
        'errorMessage' => 'my custom error message',
        'errorCode'    => -32600 // Invalid params
    ],
    [
        'key'          => 'myCustomKey2',
        'value'        => '1237485' //defined required value,
        'errorMessage' => 'myCustomKey2 is not set correctly or missing',
        'errorCode'    => -32600 // Invalid params
    ]
];

$mySpec = '3.0'

$listener = new \Timmachine\PhpJsonRpc\Listener($routes,$mySpec, $customRequirements);
```

Optional Params
---------------

[](#optional-params)

```
class foo{
    public function bar($a = 2,$b = 3, $c = 4)
    {
     return $a + $b + $c;
    }
}

// example json to make the request
// '{"jsonrpc": "2.0", "method": "foo.bar", "params":[], "id": 1}';

//example response
//{"jsonrpc": "2.0", "result": 9, "id": 1}
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a1d17647eda7ab6420a2fc3f8fdbc6a02e8d20800b7a60bf7524bc66539f68d?d=identicon)[tsmith86](/maintainers/tsmith86)

### Embed Badge

![Health badge](/badges/timmachine-php-json-rpc/health.svg)

```
[![Health](https://phpackages.com/badges/timmachine-php-json-rpc/health.svg)](https://phpackages.com/packages/timmachine-php-json-rpc)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

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

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k13](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

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

PHPackages © 2026

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