Skip to content

Instantly share code, notes, and snippets.

@daum
Created February 27, 2014 21:14
Show Gist options
  • Save daum/9259700 to your computer and use it in GitHub Desktop.
Save daum/9259700 to your computer and use it in GitHub Desktop.
Gearman Sample
<?php
// In controller
public function triggerSendNotificationsAction(Request $request)
{
// Code to get that user triggered a bunch of notifications to an array of user ids.
$userIds = array(.......);
$message = 'some message from the frontend user';
//Get Gearman and tell it to run in the background a 'job'
$this->get('gearman')->doBackgroundJob('MyDemoBundleWorker~sendNotificationsToUsers',
json_encode(array('user_ids'=>$userIds,'message'=>$message)));
return $this->renderText('Your notifications are being sent now!');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment