Reputation: 3819
I am using laravel 5. What I need is to call python gearman worker.
I have created a gearman worker in python. And I have created a gearman client in laravel 5.
I have directly added gearman client code in my controller like:
$client = new GearmanClient();
$client->addServer();
$job_data = array("func_name" => "searchTweets", "query" => "query_to_search");
$result = $client->doNormal("php_twitter_worker", json_decode($job_data));
if ($result) {
print_r($result);
}
But it throws error :
Class 'App\Http\Controllers\GearmanClient' not found
I know what is the error because I don't have GearmanClient Class in Controllers. Actually I don't know how to use it.
After doing some R&D , I found a package using gearman in laravel5 but not getting how to use it as Gearman Client and how it make a call to my python gearman worker.
Any help on this ?
Upvotes: 1
Views: 529
Reputation: 1893
Because your class is namespaced, your controller there, PHP will look for a class inside of this namespace.
Therefore, to use a class from the root namespace, you should either use a use statement or prefix the classname with \, \ being the root namespace.
use GearmanClient;
$client = new \GearmanClient();
Use one or the other, not both, my code above is actually quite confusing...
Upvotes: 2