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

ActiveSymfony-bundle[API Development](/categories/api)

olegkunitsyn/json-rpc-bundle
============================

JSON-RPC 2.0 implementation for Symfony

7.0.1(2y ago)05MITPHPPHP ^8.2

Since Mar 4Pushed 2y ago1 watchersCompare

[ Source](https://github.com/OlegKunitsyn/json-rpc-bundle)[ Packagist](https://packagist.org/packages/olegkunitsyn/json-rpc-bundle)[ RSS](/packages/olegkunitsyn-json-rpc-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (10)Versions (2)Used By (0)

JsonRpcBundle
=============

[](#jsonrpcbundle)

[JSON-RPC 2.0](https://www.jsonrpc.org/specification) implementation for Symfony.

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

[](#installation)

Make sure Composer is installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md) of the Composer documentation.

### Applications that use Symfony Flex

[](#applications-that-use-symfony-flex)

Open a command console, enter your project directory and execute:

```
composer require olegkunitsyn/json-rpc-bundle
```

### Applications that don't use Symfony Flex

[](#applications-that-dont-use-symfony-flex)

#### Step 1: Download the Bundle

[](#step-1-download-the-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
composer require olegkunitsyn/json-rpc-bundle
```

#### Step 2: Enable the Bundle

[](#step-2-enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```
# config/bundles.php
return [
    // ...
    OlegKunitsyn\JsonRpcBundle::class => ['all' => true],
];
```

Start development server:

```
php -S localhost:8000 -t public
```

Configuration
-------------

[](#configuration)

Import the main routing file or create a custom route:

```
# config/routes.yaml
rpc:
    path: /api
    controller: json_rpc_bundle.api.rpc
    methods: POST
```

Usage
-----

[](#usage)

Tag the services you want to expose and send a json-rpc payload to the RPC endpoint. The method parameter must follow the convention `{serviceKey}.{method}`

```
# config/services.yaml
services:
    App\RpcServices\:
        resource: '../src/RpcServices/'
        tags:
          - 'json_rpc_bundle'
```

```
namespace App\RpcServices;

use App\Dto\EchoDto;
use OlegKunitsyn\JsonRpcBundle\Service\AbstractRpcService;

class MyService extends AbstractRpcService
{
    public static function getServiceKey(): string
    {
        return 'myService';
    }

    public function echo(EchoDto $dto) : EchoDto
    {
        return $dto;
    }
}
```

```
namespace App\Dto;

readonly class EchoDto
{
    public function __construct(public string $value)
    {
    }
}
```

### By name (object)

[](#by-name-object)

Request:

```
curl -X POST localhost:8000/api -d '{"method": "myService.echo", "params": {"value": "hello"}, "id": "1", "jsonrpc": "2.0"}' -H 'Content-Type: application/json'
```

Response:

```
{"jsonrpc":"2.0","result":{"value":"hello"},"id":"1"}
```

### By position (array)

[](#by-position-array)

Request:

```
curl -X POST localhost:8000/api -d '{"method": "myService.echo", "params": ["hello"], "id": "second", "jsonrpc": "2.0"}' -H 'Content-Type: application/json'
```

Response:

```
{"jsonrpc":"2.0","result":{"value":"hello"},"id":"second"}
```

### Batch

[](#batch)

Request:

```
curl -X POST localhost:8000/api -d '[{"method": "myService.echo", "params": {"value": "hello"}, "id": "1", "jsonrpc": "2.0"}, {"method": "myService.echo", "params": ["hello"], "id": "second", "jsonrpc": "2.0"}]' -H 'Content-Type: application/json'
```

Response:

```
[{"jsonrpc":"2.0","result":{"value":"hello"},"id":"1"},{"jsonrpc":"2.0","result":{"value":"hello"},"id":"second"}]
```

### Response normalization

[](#response-normalization)

Responses are processed by a Symfony normalizer. Use the `RpcNormalizationContext` attribute to specify a normalization context:

```
namespace App\RpcServices;

use App\Dto\DateTimeDto;
use OlegKunitsyn\JsonRpcBundle\Response\RpcNormalizationContext;
use OlegKunitsyn\JsonRpcBundle\Service\AbstractRpcService;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;

class MyService extends AbstractRpcService
{
    public static function getServiceKey(): string
    {
        return 'myService';
    }

    #[RpcNormalizationContext([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
    public function echo(DateTimeDto $timestamp): DateTimeDto
    {
        return $timestamp;
    }
}
```

```
namespace App\Dto;

readonly class DateTimeDto
{
    public function __construct(public readonly \DateTimeImmutable $timestamp)
    {
    }
}
```

Request:

```
curl -X POST localhost:8000/api -d '{"method": "myService.echo", "params": {"timestamp": "2012-04-23T18:25:43.511Z"}, "id": "1", "jsonrpc": "2.0"}' -H 'Content-Type: application/json'
```

Response:

```
{"jsonrpc":"2.0","result":{"timestamp":"2012-04-23"},"id":"1"}
```

Roadmap
-------

[](#roadmap)

- Performance
- Security
- Code coverage

Credits
-------

[](#credits)

- Gabriel Soullier, [NanofelisJsonRpcBundle](https://github.com/nanofelis/NanofelisJsonRpcBundle)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

805d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d8b1b3de615f950843e6ffcecce92251967b3925aca390652e6a903927e0c67?d=identicon)[OlegKunitsyn](/maintainers/OlegKunitsyn)

---

Top Contributors

[![OlegKunitsyn](https://avatars.githubusercontent.com/u/2870028?v=4)](https://github.com/OlegKunitsyn "OlegKunitsyn (3 commits)")

---

Tags

apisymfonyjson-rpc

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/olegkunitsyn-json-rpc-bundle/health.svg)

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

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[api-platform/symfony

Symfony API Platform integration

323.2M67](/packages/api-platform-symfony)[meilisearch/search-bundle

Seamless integration of Meilisearch into your Symfony project.

154356.2k](/packages/meilisearch-search-bundle)[nanofelis/json-rpc-bundle

This bundle provides a JSON RPC 2.0 implementation for Symfony

1176.1k](/packages/nanofelis-json-rpc-bundle)[artyuum/request-dto-mapper-bundle

This bundle provides an easy way to automatically map the incoming request data to a DTO and optionally validate it.

515.8k](/packages/artyuum-request-dto-mapper-bundle)[rekalogika/mapper

An object mapper for PHP and Symfony. Maps an object to another object. Primarily used for transforming an entity to a DTO and vice versa.

3847.7k1](/packages/rekalogika-mapper)

PHPackages © 2026

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