bingher/transmit

v1.1.1 2022-03-16 09:26 UTC

This package is auto-updated.

Last update: 2024-11-16 15:05:19 UTC


README

thrift php 简单封装用于生成服务端及客户端

安装

composer require bingher/transmit

使用说明

  • 服务端:定义了通用调用接口invoke,传参:方法名及数组json字符串参数,继承\bingher\transmit\Server后只要写相关业务逻辑即可
<?php
require __DIR__ . '/../vendor/autoload.php';

class TransmitHandler extends \bingher\transmit\Server
{
    public function sayMsg($params)
    {
        return 'you say:' . var_export($params, true);
    }
}

$host = '0.0.0.0';
$port = 9000;

TransmitHandler::run($port, $host);

sever_start

  • 客户端:实例化客户端,调用服务端的方法及数组传参即可
<?php
require __DIR__ . '/../vendor/autoload.php';

$client = new \bingher\transmit\Client('127.0.0.1', 8000);

$res = $client->sayMsg(['msg' => 'hello huangbh']);
var_dump($res);

client_request

参考资料

./tool/thrift.exe -gen py ./tool/transmit.thrift
./tool/thrift.exe -gen php ./tool/transmit.thrift
./tool/thrift.exe -gen java ./tool/transmit.thrift