1. Go to this page and download the library: Download shso/net_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/ */
namespace The\Job\Namespace;
class someBackgroundJob extends ShSo\Net\Gearman\Job\Common
{
public function run($args)
{
if (!isset($args['userid']) || !isset($args['action'])) {
throw new ShSo\Net\Gearman\Job\Exception('Invalid/Missing arguments');
}
// Insert a record or something based on the $args
return array(); // Results are returned to Gearman, except for
// background jobs like this one.
}
}
if (!defined('NET_GEARMAN_JOB_CLASS_PREFIX'))
define('NET_GEARMAN_JOB_CLASS_PREFIX', "The\\Job\\Namespace\\");
$worker = new ShSo\Net\Gearman\Worker('localhost:4730');
$worker->addAbility('someBackgroundJob');
$worker->beginWork();
sh
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.