PHP code example of vectorface / gearman

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

    

vectorface / gearman example snippets

 php


$client = new \Vectorface\Gearman\Client();
$client->addServer();

$result = $client->doNormal('replace', 'PHP is best programming language!');
$client->doBackground('long_task', 'PHP rules... PHP rules...');
 php


$function = function($payload) {
    return str_replace('java', 'php', $payload);
};

$worker = new \Vectorface\Gearman\Worker();
$worker->addServer();
$worker->addFunction('replace', $function);

$worker->work();