1. Go to this page and download the library: Download sinergi/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/ */
sinergi / gearman example snippets
use Sinergi\Gearman\Config;
$config = (new Config())
->addServer('127.0.0.1', 4730)
->setUser('apache');
use Sinergi\Gearman\Config;
$config = new Config([
'servers' => ['127.0.0.1:4730', '127.0.0.1:4731'],
'user' => 'apache'
]);
use Sinergi\Gearman\BootstrapInterface;
use Sinergi\Gearman\Application;
class MyBootstrap implements BootstrapInterface
{
public function run(Application $application)
{
$application->add(new JobExample());
}
}
use Sinergi\Gearman\JobInterface;
use GearmanJob;
class JobExample implements JobInterface
{
public function getName()
{
return 'JobExample';
}
public function execute(GearmanJob $job)
{
// Do something
}
}
use Sinergi\Gearman\Dispatcher;
$dispatcher = new Dispatcher($config);
$dispatcher->execute('JobExample', ['data' => 'value']);