docs: rewrite JsonRpcBundle docs, add SDK docs, move them under docs/api
en/docs/api/json-rpc-bundle/README.md
new file +93
ā0
1
+
# JsonRpcBundle
2
+
3
+
:::block class="floatinginfobox"
4
+
<include>(docs/api/json-rpc-bundle/.info.md)
5
+
:::
6
+
7
+
A JSON-RPC 2.0 server for Symfony 7.2+ / 8 (PHP 8.4+).
8
+
9
+
> Building RPC services for a service-oriented architecture on Symfony has never been this easy.
10
+
11
+
Any service in your application becomes an API: implement the `IRpcService` interface and its public methods are available as JSON-RPC methods. Validation, type conversion, security, caching and OpenRPC documentation come from the code you have already written.
12
+
13
+
## From class to API
14
+
15
+
::::columns
16
+
:::col
17
+
**Your code**
18
+
19
+
```php
20
+
#[RPC\Info('User')]
21
+
final class UserApi implements IRpcService
22
+
{
23
+
public function __construct(private UserService $users) {}
24
+
25
+
/**
26
+
* Returns a user by id
27
+
* @throws UserNotFoundException
28
+
*/
29
+
#[RPC\Cache(lifetimeSecond: RPC\Cache::T_HOUR)]
30
+
public function get(int $id): UserDto
31
+
{
32
+
return $this->users->get($id);
33
+
}
34
+
}
35
+
```
36
+
:::
37
+
38
+
:::col
39
+
**Request**
40
+
41
+
```json
42
+
{"jsonrpc": "2.0", "id": 1, "method": "User.get", "params": {"id": 5}}
43
+
```
44
+
45
+
**Response**
46
+
47
+
```json
48
+
{
49
+
"jsonrpc": "2.0",
50
+
"id": 1,
51
+
"result": {"id": 5, "email": "user@example.com", "name": "John"}
52
+
}
53
+
```
54
+
:::
55
+
::::
56
+
57
+
There is nothing else to write:
58
+
59
+
* `GET /rpc` already returns OpenRPC documentation with the `User.get` method, the `UserDto` schema and the error from `@throws`, and `GET /rpc/postman` returns a ready-made Postman collection;
60
+
* a wrong `id` type returns a `-32602` error with an explanation for the parameter;
61
+
* in the prod environment the response is cached for an hour;
62
+
* the same method can be called from the console, from a Symfony Messenger queue, in a batch together with other methods, and, through extensions, as a REST endpoint or a tool for an AI agent.
63
+
64
+
## Why JsonRpcBundle
65
+
66
+
* **Documentation never lags behind the code.** OpenRPC and Postman are built from PHP types, PHPDoc, DTOs, enums and validation constraints; method names are translated according to `Accept-Language` ([API documentation](/docs/api/json-rpc-bundle/documentation)).
67
+
* **One method, many transports.** HTTP, console, Symfony Messenger, and through extensions REST, MCP, Mercure ([Asynchronous processing](/docs/api/json-rpc-bundle/functionality/async), [Console calls](/docs/api/json-rpc-bundle/functionality/cli)).
68
+
* **Painless evolution.** Several [API versions](/docs/api/json-rpc-bundle/functionality/versions) side by side (`/rpc`, `/rpc/v2`) and several [API groups](/docs/api/json-rpc-bundle/functionality/groups) in one application (public, internal, BFF), each with its own methods and tokens.
69
+
* **Fewer network requests.** [Batch](/docs/api/json-rpc-bundle/functionality/batch) with `@FROM:<id>(<field>)` dependencies, fire-and-forget [notifications](/docs/api/json-rpc-bundle/functionality/notifications), results delivered to a [webhook](/docs/api/json-rpc-bundle/functionality/callback).
70
+
* **Declarative instead of boilerplate.** [Validation](/docs/api/json-rpc-bundle/add_rpc_service/assertions), [DTOs and type conversion](/docs/api/json-rpc-bundle/add_rpc_service/params), [caching](/docs/api/json-rpc-bundle/add_rpc_service/cache) and [locking](/docs/api/json-rpc-bundle/add_rpc_service/lock) via attributes on the method.
71
+
* **Extensibility.** [Events](/docs/api/json-rpc-bundle/functionality/events) around every call and core extension points ([For developers](/docs/api/json-rpc-bundle/developers)).
72
+
73
+
:::info
74
+
<include>(change_log/latest.md)
75
+
:::
76
+
77
+
## Ecosystem
78
+
79
+
* **AI agents.** [MCP Bundle](/docs/api/mcp-bundle) exposes your RPC methods as tools for Claude Code, Cursor, Gemini CLI and OpenAI, with no extra code.
80
+
* **REST.** [REST Bundle](/docs/api/rest-bundle) publishes selected methods as a REST API with OpenAPI documentation.
81
+
* **Clients.** [JSON-RPC Client SDK](/docs/api/sdk/client) generates a PHP client with procedure classes and DTOs, [RPC TS SDK](/docs/api/sdk/ts) generates TypeScript interfaces from the OpenRPC document.
82
+
* **Rules for AI assistants.** [Instruction files](/docs/api/json-rpc-bundle/developers/ai) so that Claude Code, Codex or Cursor work with the bundle correctly.
83
+
84
+
The full list is on the [Extensions](/docs/api/json-rpc-bundle/developers/extensions) page.
85
+
86
+
## Getting started
87
+
88
+
1. [Install the bundle](/docs/api/json-rpc-bundle/installation): `composer require ufo-tech/json-rpc-bundle` and two configuration files.
89
+
2. [Add custom methods](/docs/api/json-rpc-bundle/add_rpc_service) and open `GET /rpc` to see the documentation.
90
+
3. Configure [security and other parameters](/docs/api/json-rpc-bundle/config).
91
+
4. Explore the [features](/docs/api/json-rpc-bundle/functionality/batch): batch, notifications, asynchronous processing, events.
92
+
93
+
Not sure JSON-RPC is right for you? Read the article [RPC, REST and GraphQL](/articles/api/rpc_vs_rest_vs_graphql), a short and practical look at when each approach fits.
en/docs/api/json-rpc-bundle/.info.md
new file +67
ā0
1
+
:::::columns border="1" zebra="1"
2
+
::::row
3
+
:::col width="40%"
4
+
Download
5
+
:::
6
+
7
+
:::col
8
+
[Packagist](https://packagist.org/packages/ufo-tech/json-rpc-bundle)<br>
9
+
[GitHub](https://github.com/UFO-Tech/json-rpc-bundle)
10
+
:::
11
+
::::
12
+
13
+
::::row
14
+
:::col width="40%"
15
+
Current version
16
+
:::
17
+
18
+
:::col
19
+
[](https://packagist.org/packages/ufo-tech/json-rpc-bundle)
20
+
:::
21
+
::::
22
+
23
+
::::row
24
+
:::col width="40%"
25
+
Category
26
+
:::
27
+
28
+
:::col
29
+
API
30
+
:::
31
+
::::
32
+
33
+
::::row
34
+
:::col width="40%"
35
+
Type
36
+
:::
37
+
38
+
:::col
39
+
Symfony Bundle
40
+
:::
41
+
::::
42
+
43
+
::::row
44
+
:::col width="40%"
45
+
Dependencies
46
+
:::
47
+
48
+
:::col
49
+

50
+

51
+

52
+

53
+
:::
54
+
::::
55
+
56
+
::::row
57
+
:::col width="40%"
58
+
Other details
59
+
:::
60
+
61
+
:::col
62
+

63
+

64
+

65
+
:::
66
+
::::
67
+
:::::
en/docs/api/json-rpc-bundle/change_log/latest.md
new file +1
ā0
1
+
<include>(10.4.2.md)
en/docs/api/json-rpc-bundle/change_log/10.4.2.md
new file +17
ā0
1
+
## Version 10.4
2
+
3
+
### Key changes
4
+
5
+
* [Translations for API groups](/docs/api/json-rpc-bundle/documentation): `translations/rpc/<group>.<locale>.yaml`; the group takes precedence over the language.
6
+
* Translations from extensions (`translations.paths`), the public `RpcLocaleNegotiator` service.
7
+
* 10.4.1: `IApiRouteImport`: adapter routes can be registered separately for each API group.
8
+
* 10.4.2: `RpcExecutor` is the single entry point for adapters (REST, MCP); `rpc.post_response` fires for any request source and for each executed batch item.
9
+
10
+
### What to keep in mind
11
+
12
+
* Partial base translation: a missing `description` is taken from the base translation in the `kernel.default_locale` language, not from the attribute / PHPDoc.
13
+
* REST calls now get `rpc.post_response`: cache relations and async/notification listeners start working for them.
14
+
15
+
### Environment changes
16
+
17
+
* Unchanged from 10.3.