PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Lorna Mitchell's Blog: Using Gearman from PHP

Note: This article was originally published at PHPDeveloper on 17 February 2011.
PHPDeveloper

Lorna Mitchell has a new post today about using a popular backend processing tool, Gearman, from inside of PHP. Her example gives a full overview of how to add a new job and write the worker for it to make things happen.

Basically, this application generates some PDFs from a variety of data sources, makes images, and emails it. Since the whole data processing, image handling, PDF generation process is fairly heavy, I'm putting the requests to generate these onto a gearman queue and having some workers process the jobs.

You'll need to have the Gearman server and extension installed (sample instructions here for Ubuntu) to use the sample code she gives using the Gearman_Client and GearmanWorker objects to create the pieces of the puzzle. You can find out more about the Gearman PECL extension here.