windlace / lumen-rpc by cast

Lumen RPC server and client classes
523
2
0
Package Data
Maintainer Username: cast
Package Create Date: 2019-02-06
Package Last Update: 2020-03-19
Language: PHP
License: MIT
Last Refreshed: 2024-04-18 15:17:30
Package Statistics
Total Downloads: 523
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 0
Total Forks: 2
Total Open Issues: 0

Install

composer require cast/lumen-rpc

Usage

Create config file rpc.php like this:

<?php

return [
    'config' =>  [
        'my-method',
    ]
];

Start a server:

Rpc::listen('my-method', function ($msg) {
    // do work...
    return $msg['number'] * 2;
});

Make some RPC-call from remote:

$res = Rpc::get('my-method', ['number'=>5]);

var_dump($res);

Will gets:

int(10)

Make sure you have correct config for RabbitMQ, see it in config/queue.php