profile picture

PHP daemon with fork howto part 1: Introduction

Published on 16 October 2008 - php php-fork-series work

This content is old and might be outdated.

In the past weeks, I have 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 add another part each week.

In this series, I will cover the following subjects:

  1. Part 1: An introduction to this series, links to all parts
  2. Part 2: About UNIX processes and PHP
  3. Part 3: Creating a Hello World daemon with fork()
  4. Part 4: Adding IPC (Inter Process Communication) with PHP sockets
  5. Part 5: Talking to the outer world (also with PHP sockets)
  6. 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.