limingxinleo / x-swoole-rpc
Rpc library for swoole
Installs: 2 505
Dependents: 1
Suggesters: 0
Security: 0
Stars: 16
Watchers: 4
Forks: 4
Open Issues: 0
Requires
- php: >=5.6
- ext-swoole: >=1.10
- limingxinleo/x-console-color: ^1.0
Requires (Dev)
- limingxinleo/support-str: ^1.0
- limingxinleo/x-trait-common: ^1.0
- phpunit/phpunit: >=5.6
README
安装
composer require limingxinleo/x-swoole-rpc
使用
服务端示例代码
<?php require __DIR__ . '/../vendor/autoload.php'; use Xin\Swoole\Rpc\Server; use Xin\Swoole\Rpc\Handler\Handler; class TestHandler extends Handler { public function test() { return 'success'; } } $server = new Server(); $server->setHandler('test', TestHandler::class)->serve('0.0.0.0', '11520', [ 'pid_file' => './socket.pid', 'daemonize' => false, 'max_request' => 500, // 每个worker进程最大处理请求次数 'open_eof_check' => true, 'package_eof' => "\r\n", ]);
客户端示例代码
<?php use Xin\Swoole\Rpc\Client\Client; /** * Class TestClient * @method test */ class TestClient extends Client { protected $service = 'test'; protected $host = '127.0.0.1'; protected $port = 11520; } $result = TestClient::getInstance()->test();