1. Go to this page and download the library: Download phluxor/phluxor-remote 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/ */
phluxor / phluxor-remote example snippets
hluxor\ActorSystem;
use Phluxor\Remote\Config;
use Phluxor\Remote\Kind;
use Phluxor\Remote\Remote;
use Test\ProtoBuf\HelloRequest;
use Test\ProtoBuf\HelloResponse;
\Swoole\Coroutine\run(function () {
\Swoole\Coroutine\go(function () {
$system = ActorSystem::create();
$config = new Config('localhost', 50053, Config::withUseWebSocket(true));
$remote = new Remote($system, $config);
$remote->start();
$props = ActorSystem\Props::fromFunction(
new ActorSystem\Message\ReceiveFunction(
function (ActorSystem\Context\ContextInterface $context) {
$message = $context->message();
if ($message instanceof HelloRequest) {
$context->respond(new HelloResponse([
'Message' => 'Hello from remote node',
]));
}
}
)
);
$system->root()->spawnNamed($props, 'hello');
});
});
hluxor\ActorSystem;
use Phluxor\Remote\Config;
use Phluxor\Remote\Kind;
use Phluxor\Remote\Remote;
use Test\ProtoBuf\HelloRequest;
use Test\ProtoBuf\HelloResponse;
\Swoole\Coroutine\run(function () {
\Swoole\Coroutine\go(function () {
$system = ActorSystem::create();
$config = new Config('localhost', 50052, Config::withUseWebSocket(true));
$remote = new Remote($system, $config);
$remote->start();
$future = $system->root()->requestFuture(
new ActorSystem\Ref(new ActorSystem\ProtoBuf\Pid([
'address' => 'localhost:50053',
'id' => 'hello',
])),
new HelloRequest(),
1
);
$r = $future->result()->value();
$r->getMessage(); // Hello from remote node!
});
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.