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

ActiveLibrary[API Development](/categories/api)

onnov/json-rpc-server
=====================

json rpc server

v4.0.5(2y ago)15.1k—0%MITPHPPHP &gt;=7.4CI failing

Since Jul 2Pushed 2y ago2 watchersCompare

[ Source](https://github.com/onnov/json-rpc-server)[ Packagist](https://packagist.org/packages/onnov/json-rpc-server)[ RSS](/packages/onnov-json-rpc-server/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (15)Versions (10)Used By (0)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0ade51f6579ce2770130fbd715f0634d44dfcca7999ee779083eb2ba90a0841e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f6e6e6f762f6a736f6e2d7270632d7365727665722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/onnov/json-rpc-server/?branch=master)

Json RPC 2.0 server
===================

[](#json-rpc-20-server)

Install
-------

[](#install)

[Composer](https://getcomposer.org) (recommended) Use Composer to install this library from Packagist: onnov/json-rpc-server

Run the following command from your project directory to add the dependency:

```
composer require onnov/json-rpc-server
```

Alternatively, to load the dev-master branch, add the dependency directly to the composer.json file.

composer.json

```
 "repositories": [
        {
            "type": "git",
            "url": "git@github.com:onnov/json-rpc-server.git"
        }
    ],
    "require": {
        "onnov/json-rpc-server": "dev-master"
    },

```

Use
---

[](#use)

Для автозагрузки в symfony нужно добавить:

```
  Onnov\JsonRpcServer\JsonRpcHandler:
    autowire: true

```

в файл services.yaml

### Авторизация

[](#авторизация)

Json RPC server не занимается авторизацией. Если нужна авторизация, авторизуйте пользователя любым способом, результат авторизации передайте в метод JsonRpcHandler::run, 3-м параметром **$resultAuth** в виде true или false.

Данный флаг предусмотрен только для того, что бы Json RPC server выдал стандартный ответ при отсутствии авторизации.

Если авторизация не требуется, просто передайте true 3-м параметром **$resultAuth**.

---

Если API использует авторизацию, но несколько методов должны быть доступны без авторизации, такие методы как **login** или **authCheck**эти методы можно перечислить в 4-м параметре **$methodsWithoutAuth** в виде массива:

```
$methodsWithoutAuth = ['login', 'authCheck'];
```

Эти методы будут доступны независимо от авторизации.

### Фабрика с методами

[](#фабрика-с-методами)

Создаем фабрику с помощью Интерфейса ApiFactoryInterface в методе getSubscribedServices перечисляем все используемые классы

```
public static function getSubscribedServices(): array
    {
        return [
            'Bankruptcy' => Bankruptcy::class,
            'Bankrupt' => Bankrupt::class,
        ];
    }

```

### Запуск обработчика json rpc

[](#запуск-обработчика-json-rpc)

Создаем объект JsonRpcHandler передаем в метод run( ApiFactoryInterface $apiFactory, string $json, bool $resultAuth, array $methodsWithoutAuth = \[\], bool $responseSchemaCheck = false )

метод возвращает строку json

```
use Onnov\JsonRpcServer\JsonRpcHandler;
use Onnov\JsonRpcServer\Model\ResultAuthModel;

$authRes = (new ResultAuthModel())->setSuccess(true);
$apiFactory = new ApiFactory()

$server = new JsonRpcHandler();
$res = $server->run(
    $apiFactory,
    $json,
    $resultAuth,
    $methodsWithoutAuth
    $responseSchemaCheck
)

```

### JSON RPC методы

[](#json-rpc-методы)

API Методы создаются с помощью Интерфейса `ApiMethodInterface.php`. Каджый класс с используемыми методами должен быть описан в ApiFactory.

jsonRPC запрос может выглядеть так:

```
{
  "jsonrpc": "2.0",
  "method": "Auth.check",
  "params": null,
  "id": 911
}

```

Ответ формируется в зависимости от того, что вернет метод API. Все, что возвращают методы попадает в `result`

---

Validation
==========

[](#validation)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 78.2% 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.

###  Release Activity

Cadence

Every ~161 days

Recently: every ~96 days

Total

9

Last Release

900d ago

Major Versions

v2.0.0 → v3.0.02021-01-04

v3.0.0 → v4.0.02021-05-08

v2.0.1 → v4.0.12022-12-26

PHP version history (2 changes)v2.0.0PHP &gt;=7.3

v4.0.1PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13568367?v=4)[onnov](/maintainers/onnov)[@onnov](https://github.com/onnov)

---

Top Contributors

[![onnov](https://avatars.githubusercontent.com/u/13568367?v=4)](https://github.com/onnov "onnov (43 commits)")[![oka-volga](https://avatars.githubusercontent.com/u/3319885?v=4)](https://github.com/oka-volga "oka-volga (12 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/onnov-json-rpc-server/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k373.5M3.3k](/packages/symfony-cache)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k185.6M2.4k](/packages/symfony-security-bundle)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)

PHPackages © 2026

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