PHP code example of hoa / worker

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

    

hoa / worker example snippets


if (false === Hoa\Worker\Run::widExists('demorker')) {
    Hoa\Worker\Run::register('demorker', 'tcp://127.0.0.1:123456');
}

$worker = new Hoa\Worker\Backend\Shared('demorker', 'iamapassword');
$worker->on('message', function(Hoa\Event\Bucket $bucket) {
    $data = $bucket->getData();
    // compute $data['message'].
});
$worker->run();

$worker = new Hoa\Worker\Shared('demorker');
$worker->postMessage('mail [email protected] Hello Gordon!');