2017 © Pedro Peláez
 

yii2-extension yii2-gearman

Gearman handler for PHP

image

filsh/yii2-gearman

Gearman handler for PHP

  • Tuesday, January 6, 2015
  • by Filsh
  • Repository
  • 8 Watchers
  • 39 Stars
  • 2,469 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 13 Forks
  • 5 Open issues
  • 2 Versions
  • 4 % Grown

The README.md

yii2-gearman

A wrapper for https://github.com/sinergi/gearman Thanks for Gabriel Bull, (*1)

Installation

It is recommended that you install the Gearman library through composer. To do so, add the following lines to your composer.json file., (*2)

{
    "require": {
       "filsh/yii2-gearman": "dev-master"
    }
}

Configuration

'components' => [
  'gearman' => [
      'class' => 'filsh\yii2\gearman\GearmanComponent',
      'servers' => [
          ['host' => '127.0.0.1', 'port' => 4730],
      ],
      'user' => 'www-data',
      'jobs' => [
          'syncCalendar' => [
              'class' => 'common\jobs\SyncCalendar'
          ],
          ...
      ]
  ]
],
...
'controllerMap' => [
    'gearman' => [
        'class' => 'filsh\yii2\gearman\GearmanController',
        'gearmanComponent' => 'gearman'
    ],
    ...
],

Job example

namespace common\jobs;

use filsh\yii2\gearman\JobBase;

class SyncCalendar extends JobBase
{
    public function execute(\GearmanJob $job = null)
    {
        // Do something
    }
}

Manage workers

yii gearman/start --fork=true // start the workers as a daemon and fork proces
yii gearman/restart --fork=true // restart workers
yii gearman/stop // stop workers

Example using Dispatcher

Yii::$app->gearman->getDispatcher()->background('syncCalendar', new JobWorkload([
    'params' => [
        'data' => 'value'
    ]
])); // run in background
Yii::$app->gearman->getDispatcher()->execute('syncCalendar', ['data' => 'value']); // run synchronize

The Versions

06/01 2015

dev-master

9999999-dev https://github.com/filsh/yii2-gearman

Gearman handler for PHP

  Sources   Download

MIT

The Requires

 

by Igor Maliy

extension yii

06/01 2015

v1.0

1.0.0.0 https://github.com/filsh/yii2-gearman

Gearman handler for PHP

  Sources   Download

MIT

The Requires

 

by Igor Maliy

extension yii