zf2 gearman

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

zf2 gearman

Norbert Máté
Hi,
I have to integrate Gearman in a zf2 project. I have made some search and I
found a zf2 module for this (https://github.com/mwillbanks/MwGearman). Did
anybody used this module?
I have some problem with it.
The problem is that I want to use it in a controller and this is how you
register a worker function:

$gearman->register('myJob', 'handleJob');

This would work with scripts but not with classes because I have to
transmit $this too. I have locked into the code of the module and I have
found out that I can use an array($this,'function') instead of 'handleJob'
but this does not work because Gearman worker register function does accept
only string as you can see in the documentation:
http://www.php.net/manual/en/gearmanworker.register.php

Can anybody help me? How can I use this module in a controller?

Regards,
Norbert.
Reply | Threaded
Open this post in threaded view
|

Re: zf2 gearman

till


On Friday, July 12, 2013 at 9:37 AM, Norbert Máté wrote:

> Hi,
> I have to integrate Gearman in a zf2 project. I have made some search and I
> found a zf2 module for this (https://github.com/mwillbanks/MwGearman). Did
> anybody used this module?
> I have some problem with it.
> The problem is that I want to use it in a controller and this is how you
> register a worker function:
>  
> $gearman->register('myJob', 'handleJob');
I would always use addFunction():
http://www.php.net/manual/en/gearmanworker.addfunction.php

The GearmanManager is the best project I have come across in the past years. Give it a try:
https://github.com/brianlmoon/GearmanManager

Till

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: zf2 gearman

Norbert Máté
Hi till,
    thanks for your response. I have checked GearmanManager. It is really
great but I have some problems. In the gearman workers I would need zf2
which I have tried to setup as it is described in the Bootstrap file here:
http://framework.zend.com/manual/2.0/en/user-guide/unit-testing.html

Some parts are working. For example I can use the service manager. But I
need to create links from routes too and that does not work.
Should I set up the router in GearmanManager separatly. I think this should
be done by zf2 as it does when I request a page from a browser.
Do you have any idea how could I load the whole zf2 in a gearman worker?


Regards,
Norbert.


On 13 July 2013 18:23, till <[hidden email]> wrote:

>
>
> On Friday, July 12, 2013 at 9:37 AM, Norbert Máté wrote:
>
> > Hi,
> > I have to integrate Gearman in a zf2 project. I have made some search
> and I
> > found a zf2 module for this (https://github.com/mwillbanks/MwGearman).
> Did
> > anybody used this module?
> > I have some problem with it.
> > The problem is that I want to use it in a controller and this is how you
> > register a worker function:
> >
> > $gearman->register('myJob', 'handleJob');
> I would always use addFunction():
> http://www.php.net/manual/en/gearmanworker.addfunction.php
>
> The GearmanManager is the best project I have come across in the past
> years. Give it a try:
> https://github.com/brianlmoon/GearmanManager
>
> Till
>