herrjeh42
herrjeh42

Reputation: 2793

How to install mmoreramerino/GearmanBundle with Symfony 2.1.x?

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');

Upvotes: 0

Views: 1079

Answers (1)

seferov
seferov

Reputation: 4161

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(),

Upvotes: 1

Related Questions