Create daemons in PHP

 

Kevin van Zonneveld wrote a life saving article that saved me quite a bit of time; Everyone knows PHP can be used to create websites. But it can also be used to create desktop applications and commandline tools. And now with a class called System_Daemon, you can even create daemons using nothing but PHP. And did I mention it was easy?

What is a Daemon?

A daemon is a Linux program that run in the background, just like a ‘Service‘ on Windows. It can perform all sorts of tasks that do not require direct user input. Apache is a daemon, so is MySQL. All you ever hear from them is found in somewhere in /var/log, yet they silently power over 40% of the Internet.

You reading this page, would not have been possible without them. So clearly: a daemon is a powerful thing, and can be bend to do a lot of different tasks.

Why PHP?

Most daemons are written in C. It’s fast & robust. But if you are in a LAMP oriented company like me, and you need to create a lot of software in PHP anyway, it makes sense:

  • Reuse & connect existing code Think of database connections, classes that create customers from your CRM, etc.
  • Deliver new applications very fast PHP has a lot of build in functions that speed up development greatly.
  • Everyone knows PHP (right?) If you work in a small company: chances are there are more PHP programmers than there are C programmers. What if your C guy abandons ship? Admittedly it’s a very pragmatic reason, but it’s the same reason why Facebook is building HipHop.

Read the full article here >>Create daemons in PHP.

One Reply to “Create daemons in PHP”

  1. Hi,
    Really interesting article. I agree that PHP is really well suited to system administration tasks – in our case anyway it allows us to develop the automation of backend tasks much faster than if we were using bash/perl with the added advantage of the web developers being able to fix things when our sys admin is off.

    We are about to build some new server code which intergrates with ActiveMQ and I think it’s a pefect excuse to try out this lib!

    Another semi related article I found recently was this one outlining cronjob management from PHP – http://net.tutsplus.com/tutorials/php/managing-cron-jobs-with-php-2

    Really enjoy your blog, it’s staying firmly in my RSS reader.

    Kind Regards,
    Jamie
    http://www.roastinghosting.com

Leave a Reply

Your email address will not be published. Required fields are marked *