2017 © Pedro Peláez
 

symfony-bundle symfony-gearman-bundle

Integrates Gearman into Symfony2

image

isometriks/symfony-gearman-bundle

Integrates Gearman into Symfony2

  • Friday, January 13, 2017
  • by isometriks
  • Repository
  • 1 Watchers
  • 0 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Symfony Gearman Bundle

Installation

composer.json

``` yaml { "require": { "laelaps/symfony-gearman-bundle": "1.*@dev" } }, (*1)


### config.yml ``` yaml laelaps_gearman: servers: - localhost:4730

OR, (*2)

``` yaml laelaps_gearman: servers: "localhost:4730,localhost:4731", (*3)



### app/AppKernel.php ``` php <?php public function registerBundles() { $bundles = array( // ... new Laelaps\GearmanBundle\GearmanBundle(), // ... ); }

Worker supervisor cron tool

There is a simple supervisor bash script available. For instructions, see:, (*4)

https://github.com/laelaps/symfony-gearman-bundle/issues/2#issuecomment-16257507, (*5)

Examples

Worker

``` php <?php, (*6)

// AcmeDemoBundle\Worker\ExampleWorker.php, (*7)

namespace AcmeDemoBundle\Worker;, (*8)

use GearmanJob; use Laelaps\GearmanBundle\Annotation as Gearman; use Laelaps\GearmanBundle\Worker; use Symfony\Component\Console\Output\OutputInterface;, (*9)

class ExampleWorker extends Worker { /** * @Gearman\PointOfEntry(name="example_job_name") * @param GearmanJob $job * @param Symfony\Component\Console\Output\OutputInterface $output * @return boolean returning false means job failure */ public function doExampleJob(GearmanJob $job, OutputInterface $output) { // do your job } }, (*10)


### Running worker Symfony Style Notation

$ ./app/console gearman:worker:run AcmeBundle:ExampleWorker, (*11)


_Note that this would look for Acme\Bundle\AcmeBundle\Worker\ExampleWorker_

$ ./app/console gearman:worker:run ./src/AcmeDemoBundle/Worker/ExampleWorker.php, (*12)


Wildcard is also available (not recommended but possible - results in single process for multiple workers):

$ ./app/console gearman:worker:run "./src/AcmeDemoBundle/Worker/*.php", (*13)


Runs all workers from all bundles:

$ ./app/console gearman:worker:run "./src//Worker/.php", (*14)


### Calling job from controller ``` php <?php class ExampleController { public function exampleAction() { // job name taken from PointOfEntry annotation $this->get('laelaps.gearman.client')->doBackground('example_job_name', $optionalWorkload = ''); } }

Calling job from command line

$ ./app/console gearman:job:run example_job_name
$ ./app/console gearman:job:run example_job_name optional_workload_string

The Versions

13/01 2017

dev-master

9999999-dev https://github.com/laelaps/symfony-gearman-bundle

Integrates Gearman into Symfony2

  Sources   Download

MIT

The Requires

 

by Mateusz Charytoniuk

bundle symfony gearman

12/08 2013

1.x-dev

1.9999999.9999999.9999999-dev https://github.com/laelaps/symfony-gearman-bundle

Integrates Gearman into Symfony2

  Sources   Download

MIT

The Requires

 

by Mateusz Charytoniuk

bundle symfony gearman

12/08 2013

1.0.0

1.0.0.0 https://github.com/laelaps/symfony-gearman-bundle

Integrates Gearman into Symfony2

  Sources   Download

MIT

The Requires

 

by Mateusz Charytoniuk

bundle symfony gearman