See the example worker.
A worker is the process that runs the actions. It has three components:
The following code is all there is to it:
use AlphaRPC\Worker\Runner as WorkerRunner;
use AlphaRPC\Worker\Service;
$worker = new WorkerRunner(
'tcp://127.0.0.1:61003', // Worker Handler address
'./ipc' // Writable directory for IPC files.
);
$worker->forkAndRunService(function (Service $service) {
$service->addAction(
// Name of the Action.
'reverse',
// Implementation of the Action.
function($param) { return strrev($param); }
);
});
$worker->run();
To run the worker:
php worker.php
Now you can use the client to perform the Action. See Using the Client.