1. Go to this page and download the library: Download easyswoole/rpc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use EasySwoole\Rpc\Config;
use EasySwoole\Rpc\Protocol\Response;
use EasySwoole\Rpc\Rpc;
use EasySwoole\Rpc\Tests\Service\ModuleOne;
use EasySwoole\Rpc\Tests\Service\ServiceOne;
use Swoole\Http\Server;
e($service);
$http = new Server('0.0.0.0', 9501);
$rpc->attachServer($http);
$http->on('request', function ($request, $response) use($rpc){
$client = $rpc->client();
$ctx1 = $client->addRequest('Service.Module');
$ctx2 = $client->addRequest('Service.Module.action');
$ctx2->setArg('xxx');
$ctx2->setOnSuccess(function (Response $response){
var_dump($response->getMsg());
});
$client->exec();
});
$http->start();
public static function mainServerCreate(EventRegister $register)
{
$config = new \EasySwoole\Rpc\Config();
$config->getServer()->setServerIp('127.0.0.1');
$rpc = new \EasySwoole\Rpc\Rpc($config);
$service = new \EasySwoole\Rpc\Tests\Service\ServiceOne();
$service->addModule(new \EasySwoole\Rpc\Tests\Service\ModuleOne());
$rpc->serviceManager()->addService($service);
$rpc->attachServer(ServerManager::getInstance()->getSwooleServer());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.