Skip to content


Subversion checkout URL

You can clone with
Download ZIP


kvz edited this page · 3 revisions
Clone this wiki locally

System_Daemon is a PHP class that allows developers to easily create daemons with simple syntax like:


Daemon? ¶

A Daemon on Linux is like a service on Windows. It runs silently in the background and is not dependent on user interaction. In the background it can perform all kinds of tasks. Receiving mail, restructuring or denormalizing databases, process statistics for your site and save results as flat HTML to relieve resources and keep user interaction snappy, etc.

Daemons are usually written in deeper languages like C (Apache is a daemon, so is Postfix for example), but it can in some occasions be beneficial to write one in PHP.

For instance, if your website requires some heavy processing, you can just make use of existing PHP code & includes, and move this heavy processing from the user interface, to the background.

Some people use crontabs for this. Crontab is fine but it only allows you to run a PHP file every minute or so.

  • What if the previous run hasn’t finished yet?
  • What if you want to trigger a process the moment a record is inserted?
  • What if you want to keep track of multiple runs and store data in memory.
  • What if you want to keep your application listening (on a socket for example)

Crontabs are a bit rude for this. Creating a daemon would offer a little more elegance & possibilities.
Features ¶

  • Support for PEAR’s Log package
  • Simple syntax
  • Methods to determine OS and write startup files (init.d)
  • Can run with or without PEAR (PEAR adds more elegance & functionality)
  • Default signal handlers, but optionally reroute signals to your own handlers.
  • Log levels comply with PEAR_LOG_ levels but are called SYSTEM_DAEMON_LOG_ for (in)dependency reasons
  • Set options like max RAM usage

Current status ¶

The class is currently still under development. There is a working prototype in the Trunk, but it can potentially still be dangerous so please use at own risk.
Changelog ¶

Report Issues:[]=System_Daemon&status=All

Read docs:

Something went wrong with that request. Please try again.