PHPackages                             nytris/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. nytris/rpc

ActiveProject[API Development](/categories/api)

nytris/rpc
==========

02PHPCI passing

Since May 25Pushed 11mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Nytris RPC
==========

[](#nytris-rpc)

[![Build Status](https://github.com/nytris/rpc/workflows/CI/badge.svg)](https://github.com/nytris/rpc/actions?query=workflow%3ACI)

Remote Procedure Call abstraction for PHP.

What is it?
-----------

[](#what-is-it)

Nytris RPC is a PHP library that provides a robust, asynchronous Remote Procedure Call (RPC) implementation. It allows you to make calls to remote endpoints in an asynchronous manner using ReactPHP streams for communication, with the ability to pause and resume the transport layer when needed.

How does it work?
-----------------

[](#how-does-it-work)

The library provides a transport layer that can be used to send and receive messages to and from a remote endpoint. It uses ReactPHP for asynchronous operations and provides a Promise-based API for handling responses.

The architecture consists of several key components:

- **RpcFactory:** Creates and configures RPC instances: the standard library entrypoint.
- **Transport:** Handles the sending and receiving of messages.
- **CallTable:** Manages active RPC calls and their callbacks.
- **Dispatcher:** Routes incoming RPC calls to the appropriate handlers.
- **Handler:** Implements the user-defined business logic for handling RPC calls.
- **Framing Protocol:** Handles message framing for reliable message boundaries (defaults to PHP `serialize()`-based).

Requirements
------------

[](#requirements)

- PHP 8.1 or later
- [ReactPHP](https://reactphp.org/) (installed automatically as a dependency)

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

[](#installation)

Install this package with Composer:

```
$ composer require nytris/rpc
```

Usage
-----

[](#usage)

### Simple example using named pipes (FIFOs)

[](#simple-example-using-named-pipes-fifos)

As a simple example, create two named pipes (FIFOs) for communication between the server and client processes. In reality, you would likely use sockets instead.

```
mkfifo server_to_client
mkfifo client_to_server
```

`My/App/Handler/MyCommandHandler.php`

```
