limingxinleo / swoft-rpc-client
其他框架调用Swoft RPC服务的客户端
1.0.0
2018-07-17 13:21 UTC
Requires
- php: >=7.0
- limingxinleo/x-trait-common: ^1.1
Requires (Dev)
- phpunit/phpunit: ^5.7
- swoft/process: ^1.0
- swoft/rpc: ^1.0
- swoft/rpc-server: ^1.0
- swoft/swoole-ide-helper: dev-master
- swoft/task: ^1.0
This package is auto-updated.
Last update: 2024-12-17 19:56:16 UTC
README
安装
composer require limingxinleo/swoft-rpc-client
使用
定义客户端
<?php namespace SwoftTest\Rpc\Testing\Clients; use SwoftTest\Rpc\Testing\Lib\DemoServiceInterface; use Swoftx\Rpc\Client\Client; /** * Class DemoService * @package SwoftTest\Rpc\Testing\Clients * @method version() */ class DemoService extends Client { /** @var PoolName */ protected $name = 'demo'; /** @var Pool ip */ protected $ip = '127.0.0.1'; /** @var Pool port */ protected $port = 8099; /** @var Service interface */ protected $interface = DemoServiceInterface::class; }
复制服务提供方的接口
<?php /** * Swoft Entity Cache * * @author limx <715557344@qq.com> * @link https://github.com/limingxinleo/swoft-rpc-client */ namespace SwoftTest\Rpc\Testing\Lib; use Swoft\Core\ResultInterface; /** * Interface DemoServiceInterface * @package SwoftTest\Db\Testing\Lib * @method ResultInterface deferVersion() */ interface DemoServiceInterface { public function version(); }
调用
<?php use SwoftTest\Rpc\Testing\Clients\DemoService; $client = DemoService::getInstance(); echo $client->version();