watch('ExampleTube'); // this hangs until a Job is produced. //for($i = 0; $i < 1000; $i++) { while (true) { $job = $pheanstalk->reserve(); try { $jobPayload = $job->getData(); $jobPayload = json_decode($jobPayload); echo date('Y-m-d H:i:s') . ' ' . $jobPayload->id . PHP_EOL; //usleep(100); //sleep(2); // If it's going to take a long time, periodically // tell beanstalk we're alive to stop it rescheduling the job. $pheanstalk->touch($job); //sleep(2); // eventually we're done, delete job. $pheanstalk->delete($job); } catch (\Exception $e) { // handle exception. // and let some other worker retry. $pheanstalk->release($job); } }