This is a step-by-step tutorial to build a multithreaded daemon in PHP. I will point out several problems caused by a greedy implementation and will give some ways to solve them. I will also have a look at which functions are provided by PHP, what are their advantages and their drawbacks, and how to use them. I will finally give a working implementation of a class that would expose every functions needed to run such a daemon. The implementation will be written in PHP5.
Below are the steps of this tutorial :
- Introduction (this part)
- Why to use a daemon ?
- What is provided by PHP to handle multithreading ?
- Roots of a conceptual implementation
- The basic implementation of the multithreading class
- Limitations of the basic implementation and future work.