0

I am pretty new to Symfony 2 and brand new to Gearman. I am looking for a bundle to integrate Symfony 2 with Gearman.

mmoreramerino's bundle seems to be the most popular bundle according to packagist. Unfortunately something seems to be broken, the autoloader does not find the bundle.

Fatal error: Class 'Mmoreramerino\GearmanBundle\MmoreramerinoGearmanBundle' not found in ...

I tried switching to "dev-development" as I got from the issues that it was fixed in this branch, but it did not work for me as well.

Question: How can I install this bundle using Symfony 2.1.x? Question 2: Are there any working & documented alternatives?

Edit In case someone else comes across this question: Here is how I got it up and running!

  1. Install gearman, libgearman, the PECL extension for PHP (use recent versions!)
  2. check that gearman shows up in phpinfo() (both cli and webserver version)
  3. start gearmand in terminal 1 using "gearmand --verbose INFO" (you will see workers & clients connect to gearman - or not ;-))
  4. start in terminal 2 reverse_worker.php from the gearman php extension example directory
  5. start in terminal 3 reverse_client.php from the gearman php extension example directory
  6. If this is working, you are ready for Symfony: install mmoreramerino/GearmanBundle using "dev-development"
  7. copy dev.base.yml from the bundle to app/config/gearman/dev.yml
  8. Now add TestWorker.php to your bundle as outlined in the documentation
  9. enable the testWorker by using the console script "php app/console gearman:job:execute MmoreramerinoGearmanBundleWorkerstestWorker~test"
  10. now you are able to send jobs to the listening testWorker in a Symfony controller (or somewhere else in Symfony). I had to specify the server though I am using the default host/port.

    $gearman = $this->get('gearman');
    $gearman->setServer('127.0.0.1',4730);
    $gearman->doNormalJob('MmoreramerinoGearmanBundleWorkerstestWorker~test');

Code Lღver
  • 15,573
  • 16
  • 56
  • 75
herrjeh42
  • 2,782
  • 4
  • 35
  • 47

1 Answers1

1

To install the bundle, you need to add the following line to composer.json

"Mmoreramerino/GearmanBundle": "dev-development"

and run composer update;

Then register it in app/AppKernel.php (it seems you have already done this)

new Mmoreramerino\GearmanBundle\MmoreramerinoGearmanBundle(),
seferov
  • 4,111
  • 3
  • 37
  • 75
  • When I clear the Symfony cache via GearmanBundle via "php app/console cache:clear --no-warmup" I am getting an error "can't find settings file in path "/vol/www/dsearch.dev/htdocs/dsearch/app/config/gearman/dev.yml" What is supposed to be in this file? – herrjeh42 Feb 08 '13 at 11:17
  • you must configure your app http://mmoreramerino.github.com/GearmanBundle/settings.html – seferov Feb 08 '13 at 11:24
  • Oh, thanx, missed that... (my fatal error problem probably occured as I started with the v01 and probably something was still cached anywhere...). Now it is almost working, Symfony states "Deprecated: GearmanClient::do(): Use GearmanClient::doNormal() in ../Service/GearmanClient.php line 111 ". Did you fix this for yourself in the bundle code? I saw quite a few forks on Github, maybe it is fixed there? – herrjeh42 Feb 08 '13 at 12:00
  • 1
    Found it in the source code comments how to work around the deprecated warnings. Note to self: RTFM ;-) – herrjeh42 Feb 08 '13 at 12:03