PHPackages                             ufo-tech/json-rpc-client-sdk - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. ufo-tech/json-rpc-client-sdk

ActiveLibrary[Queues &amp; Workers](/categories/queues)

ufo-tech/json-rpc-client-sdk
============================

Simple clientSDK builder for any json-RPC servers

4.3.0(1mo ago)33.0k↓14.3%1[1 issues](https://github.com/UFO-Tech/json-rpc-client-sdk/issues)[1 PRs](https://github.com/UFO-Tech/json-rpc-client-sdk/pulls)1MITPHPPHP &gt;=8.3

Since Jul 25Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/UFO-Tech/json-rpc-client-sdk)[ Packagist](https://packagist.org/packages/ufo-tech/json-rpc-client-sdk)[ Docs](https://docs.ufo-tech.space/bin/view/docs/JsonRpcClientSdk/?language=en)[ RSS](/packages/ufo-tech-json-rpc-client-sdk/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (30)Versions (30)Used By (1)

json-rpc-client-sdk
===================

[](#json-rpc-client-sdk)

[![Ukraine](https://camo.githubusercontent.com/1bdf379c1ec9fb38773a34b39770476d6afc11a6414cf9b220f7ac744eb4c693/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2544302541312544302542422544302542302544302542322544302542302d2544302541332544302542412544312538302544302542302544312539372544302542442544312539362d79656c6c6f773f6c6162656c436f6c6f723d626c7565)](https://camo.githubusercontent.com/1bdf379c1ec9fb38773a34b39770476d6afc11a6414cf9b220f7ac744eb4c693/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2544302541312544302542422544302542302544302542322544302542302d2544302541332544302542412544312538302544302542302544312539372544302542442544312539362d79656c6c6f773f6c6162656c436f6c6f723d626c7565)

Simple clientSDK builder for any json-RPC servers

[![License](https://camo.githubusercontent.com/5f10cda952d684cb9142391c760fff757740755bff79ec52769d1650f80165bb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e3f6c6162656c436f6c6f723d376238313835)](https://camo.githubusercontent.com/5f10cda952d684cb9142391c760fff757740755bff79ec52769d1650f80165bb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e3f6c6162656c436f6c6f723d376238313835)[![Size](https://camo.githubusercontent.com/fd81e61b97546e7125e86ac733b5ab08a42f05a5a85bae1143bcd94071e80413/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f75666f2d746563682f6a736f6e2d7270632d636c69656e742d73646b3f6c6162656c3d53697a652532306f662532307468652532307265706f7369746f7279)](https://camo.githubusercontent.com/fd81e61b97546e7125e86ac733b5ab08a42f05a5a85bae1143bcd94071e80413/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f75666f2d746563682f6a736f6e2d7270632d636c69656e742d73646b3f6c6162656c3d53697a652532306f662532307468652532307265706f7369746f7279)[![package_version](https://camo.githubusercontent.com/80fcfe80714712e7f0c00e089d019917cb9fbd71e92c6c8d3ff83bcf7f0e23b5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f75666f2d746563682f6a736f6e2d7270632d636c69656e742d73646b3f636f6c6f723d626c7565266c6162656c3d4c617465737425323056657273696f6e266c6f676f3d5061636b6167697374266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d376238313835)](https://camo.githubusercontent.com/80fcfe80714712e7f0c00e089d019917cb9fbd71e92c6c8d3ff83bcf7f0e23b5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f75666f2d746563682f6a736f6e2d7270632d636c69656e742d73646b3f636f6c6f723d626c7565266c6162656c3d4c617465737425323056657273696f6e266c6f676f3d5061636b6167697374266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d376238313835)[![fork](https://camo.githubusercontent.com/9bcd4c7a2b31afa1b18630581fb11317a3cfb8ab53e5f26dd246190ed14262b2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f75666f2d746563682f6a736f6e2d7270632d636c69656e742d73646b3f636f6c6f723d677265656e266c6f676f3d676974687562267374796c653d666c6174)](https://camo.githubusercontent.com/9bcd4c7a2b31afa1b18630581fb11317a3cfb8ab53e5f26dd246190ed14262b2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f75666f2d746563682f6a736f6e2d7270632d636c69656e742d73646b3f636f6c6f723d677265656e266c6f676f3d676974687562267374796c653d666c6174)

See the [Documentations](https://docs.ufo-tech.space/bin/view/docs/JsonRpcClientSdk/?language=en)
=================================================================================================

[](#see-the-documentations)

New in version 4.2
==================

[](#new-in-version-42)

### ⚙️ Service parameters for UFO-json-rpc servers

[](#️-service-parameters-for-ufo-json-rpc-servers)

Support for **service-level RPC parameters** has been added for servers implemented with **UFO-json-rpc**.

The SDK now allows request configuration via a **fluent chain**, without changing method signatures.

### 🔹 Basic call (as before)

[](#-basic-call-as-before)

```
$userService->list();
```

### 🔹 Cache control

[](#-cache-control)

```
$userService
    ->withoutCache()
    ->list();
```

### 🔹 Passing service metadata

[](#-passing-service-metadata)

```
$userService
    ->rayId('someRayId')
    ->list();
```

### 🔹 Async-specific parameters

[](#-async-specific-parameters)

For async procedures, additional execution control options are available:

```
$asyncUserService
    ->withCache()
    ->rayId('someRayId')
    ->timeout(30) // timeout in seconds
    ->callback('https://some.url/hook') // webhook callback
    ->list();
```

### 📌 Notes

[](#-notes)

- Service parameters are **not passed as business method arguments**.
- They are applied at the **RPC context level** and handled by the server.
- Works **only with UFO-json-rpc compatible servers**.
- The SDK remains **type-safe** — method signatures are unchanged.

New in version 4.1
==================

[](#new-in-version-41)

### 🔍 Filtering methods during SDK generation

[](#-filtering-methods-during-sdk-generation)

The SDK supports skipping RPC methods during generation.
This is done using the `ignoredMethods` option, which accepts a list of masks.

**📌 Mask Rules**

- `*` — any sequence of characters
- `!` at the beginning — **inversion (always generate)**
- `&` at the beginning or after `!` — indicates a sync request
- `~` at the beginning or after `!` — indicates an async request
- Other characters are **literals**, meaning they represent themselves

**✔️ Example masks**

MaskDescription`AdminApi.*`ignores all methods of `AdminApi` class`Command.run`ignores only `Command.run``#Command.run`ignores only `Command.run` in sync API`*.delete`ignores all `delete()` methods in any class`!~Comment.delete`**always generates `Comment.delete` for async API even if `*.delete` blocks it**`*.*Test`ignores all methods ending with `Test`**🚫 Prohibited**

MaskReason`User.?pdate``?` is not supported`~&User.update``~` and `&` in one mask is not supported`[A-Z]*.create`regex is not supported**📎 Usage Example**

```
$configHolder = new ConfigsHolder(
    docReader: new HttpReader($apiUrl),
    projectRootDir: getcwd(),
    apiVendorAlias: $vendorName,
    ignoredMethods: [
        'AdminApi.*',
        'Command.run',
        '*.delete',
        '!Comment.delete',
        '*.*Test'
    ]
);
```

Masks allow you to easily remove service procedures, test methods, and unwanted CRUD operations from SDK generation.

Generate SDK
------------

[](#generate-sdk)

Run cli command `php bin/make.php`

```
$ php bin/make.php http://some.url/api
  > Enter API vendor name: some_vendor
  > Enter methods to ignore (comma-separated) or empty: *.delete,!Comment.delete
```

Or

```
$ php bin/make.php
```

Use SDK
-------

[](#use-sdk)

This example shows working with the generated SDK. IMPORTANT: You may have other procedure classes. The example only shows the concept of interaction.

```
