Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony2 Mmoreram GearmanClient fails to load #167

Closed
marcosrachid opened this issue Mar 23, 2016 · 7 comments
Closed

Symfony2 Mmoreram GearmanClient fails to load #167

marcosrachid opened this issue Mar 23, 2016 · 7 comments

Comments

@marcosrachid
Copy link

Hello Mmoreram,

I'm facing some problems with the GearmanBundle, since after the process of installation succeeded, I can find all my jobs and workers:

$ app/console gearman:worker:list
@worker:
HeloBundle\Workers\PushWorker
callablename: HeloBundleWorkersPushWorker
Jobs:

  • Development #1
    name: sendPushJob
    callablename: HeloBundleWorkersPushWorker~sendPushJob

@worker: HeloBundle\Workers\EmailWorker
callablename: HeloBundleWorkersEmailWorker
Jobs:

  • Ignore class #2
    name: sendMailJob
    callablename: HeloBundleWorkersEmailWorker~sendMailJob

As you can se, my gearman is installed on php:

$ php -i | grep gearman | grep enabled
gearman support => enabled

But when I call this:

try
 {
                $gearman = $this->container->get('gearman');
                $gearman->doBackgroundJob('HeloBundleWorkersPushWorker~sendPushJob', json_encode(array(
                        'tags' => $tags,
                        'message' => $message,
                        'all' => $all
                    )));
                $flash['type'] = 'notice';
                $flash['message'] = 'Success.';
            } catch (\Exception $e) {
                $flash['type'] = 'warning';
                $flash['message'] = 'Error.';
            }

It returns me this message:

request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\ClassNotFoundException: "Attempted to load class "GearmanClient" from the global namespace. Did you forget a "use" statement for "Mmoreram\GearmanBundle\Service\GearmanClient"?" at /var/www/stage/vendor/mmoreram/gearman-bundle/Mmoreram/GearmanBundle/Service/GearmanClient.php line 90 {"exception":"[object](Symfony\Component\Debug\Exception\ClassNotFoundException%28code: 0%29: Attempted to load class "GearmanClient" from the global namespace.nDid you forget a "use" statement for "Mmoreram\GearmanBundle\Service\GearmanClient"? at /var/www/stage/vendor/mmoreram/gearman-bundle/Mmoreram/GearmanBundle/Service/GearmanClient.php:90)"} []

The bundle can't load the native GearmanClient() on global scope. Can you help me with this ?

@daum
Copy link
Collaborator

daum commented Mar 23, 2016

I think you need to install and enable the php gearman extension. That's the error you are seeing.

@marcosrachid
Copy link
Author

The Extension is already installed

gearman

gearman support enabled
extension version 1.1.2
libgearman version 1.0.6
Default TCP Host localhost
Default TCP Port 4730

@daum
Copy link
Collaborator

daum commented Mar 23, 2016

You sure it's loaded in whatever environment you are getting the error in? Ie on CLI php -I|grep gearman. Or phpinfo in your browser ? It's saying it can't find it, that class is part of that module.

@marcosrachid
Copy link
Author

I'm getting this from both "php -i" and browser.

Actually, I already tested in an external file and it instantiates the native GearmanClient normally, but on the Mmoreram GearmanBundle It is returning this error.

Could it be the apxs2 ?

@daum
Copy link
Collaborator

daum commented Mar 24, 2016

Not sure then on that one then. If you can run a sample PHP app via the same environment, ie
$gearman = new \GearmanClient(); and it doesn't error then I'm stumped.

@bmeynell
Copy link
Contributor

The bundle has a class named GearmanClient. Did you define a DIC parameter
that extends or overrides that class?

@marcosrachid
Copy link
Author

I found it.

It seems the apache was pointing to a different conf.d.

Thank you guys for the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants