Last weeks, I’ve been writing a daemon in PHP for my work at Alphacomm. It now is quite finished, and I decided to share this knowledge with you in a tutorial.
Another reason for writing this tutorial, is the lack of information available at the web on this subject. Generally, it’s very scattered and not really accessible. Also, most information I found about it, talked about a specific solution, rather than taking a more general approach. So, I decided to write a howto in a series of articles on PHP fork()-ing and daemons. I expect to post each week another part, due to my busy schedule.
In this series, I will cover the following subjects:
- Part 1: An introduction to this series, links to all parts
- Part 2: About UNIX processes and PHP
- Part 3: Creating a Hello World daemon with fork()
- Part 4: Adding IPC (Inter Process Communication) with PHP sockets
- Part 5: Talking to the outer world (also with PHP sockets)
- Part 6: Errata and other stuff (not sure of this one)
Disclaimer: these can change ;)
At last, I’d like to thank the guys who wrote Nanoweb, which really helped me to understand the whole process of creating and managing processes with PHP fork(). However, if you ever plan to actually read that sourcecode yourself, be warned. It is not for the faint-hearted.