PHP code example of easyswoole / sync-invoker

1. Go to this page and download the library: Download easyswoole/sync-invoker 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/ */

    

easyswoole / sync-invoker example snippets


use EasySwoole\SyncInvoker\AbstractDriver;
use EasySwoole\SyncInvoker\SyncInvoker;
use EasySwoole\SyncInvoker\Worker;
otected function actionNotFound()
    {
        $this->response($this->getRequest()->getAction().' not found');
    }

}

$invoker = new SyncInvoker();
$invoker->getConfig()->setDriver(new Driver());
$invoker->getConfig()->setOnWorkerStart(function (Worker $worker){
    var_dump('worker start at Id '.$worker->getArg()['workerIndex']);
});

$http = new swoole_http_server("0.0.0.0", 9501);

$invoker->attachServer($http);

$http->on("request", function ($request, $response)use($invoker) {
    $ret = $invoker->invoke()->plus(1,2);
    var_dump($ret);

    $ret = $invoker->invoke()->plus2(1,2);
    var_dump($ret);
});

$http->start();