<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Tue, 22 May 2012 13:11:05 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Simas Toleikis' Blog: Writing a PHP daemon application]]></title>
      <guid>http://www.phpdeveloper.org/news/15768</guid>
      <link>http://www.phpdeveloper.org/news/15768</link>
      <description><![CDATA[<p>
<i>Simas Toleikis</i> has a new post today looking at a method he's found for creating <a href="http://simas.posterous.com/writing-a-php-daemon-application">a simple daemon application</a> in PHP. He gives you the basic outline of how it works (with a bit of code included) but not a specific example.
</p>
<blockquote>
There is a special group of applications that require a different PHP script execution model. [...] All of [these special] applications need to be run in the background as daemons - something that PHP was never designed/supposed to be good at. The plain C language is a weapon of choice when it comes to writing a daemon implementation, but then again, if the application in question does not depend on high performance and concurrency - PHP can do the job quite well.
</blockquote>
<p>
He talks about using the command line interface to run the scripts, creating the while loop to keep execution going and creating the non-blocking socket so that the script can accept new client connections.  He also mentions using <a href="http://upstart.ubuntu.com/">upstart</a> to run the script in the background and the <a href="http://pecl.php.net/package/proctitle/">proctitle</a> PECL extension to give the process a custom name in the process list. He also touches on log files and forking/parallel processing.
</p>]]></description>
      <pubDate>Wed, 19 Jan 2011 11:51:34 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Re-Cycled Air Blog: PHP Dark Arts: Daemonizing a Process]]></title>
      <guid>http://www.phpdeveloper.org/news/15356</guid>
      <link>http://www.phpdeveloper.org/news/15356</link>
      <description><![CDATA[<p>
On the Re-Cycled Air blog <i>Jack Slingerland</i> has posted another in his "Dark Arts" series looking at some of the lesser used PHP features. This time he focuses in on <a href="http://www.re-cycledair.com/php-dark-arts-daemonizing-a-process">daemonizing a process</a> by forking it off into the background.
</p>
<blockquote>
One of the many things you don't often do with PHP (actually, I'm not sure you do this much with any language) is daemonize a process.  A daemon is program that runs in the background (read more <a href="http://en.wikipedia.org/wiki/Daemon_%28computer_software%29">here</a>).  On Unix systems, processes are usually created by forking the init process and then manipulating the process to your liking.  To create a daemon though, you need to get the init process to adopt your process.  To do that, as soon as you fork the parent process, you kill the parent.  Since you child process is parent-less, the init process generally adopts it.  Once that happens, your process has been daemonized.
</blockquote>
<p>
He uses the <a href="http://php.net/pcntl_fork">pcntl_fork</a> function to spawn off the child process, detach it from a terminal window, create a ".pid" file so the system knows about it and then, of course, have the child script do something.
</p>]]></description>
      <pubDate>Fri, 29 Oct 2010 11:02:36 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Kevin Schroeder's Blog: You want to do WHAT with PHP? Chapter 8]]></title>
      <guid>http://www.phpdeveloper.org/news/15184</guid>
      <link>http://www.phpdeveloper.org/news/15184</link>
      <description><![CDATA[<p>
On his blog today <i>Kevin Schroeder</i> has the latest in a series of excerpts from his book "You Want to Do WHAT with PHP?" - a section of the <a href="http://www.eschrade.com/page/want-what-with-chapter-4c9b8841">chapter on daemons</a>.
</p>
<blockquote>
PHP is a language generally not suited for running daemons.  That said, PHP can do it, and in certain circumstances does it sufficiently for the job.  In this chapter we look at some of the things you need to know about to build a PHP-based daemon.  This excerpt doesn't feature any code, but it does set the foundation for why I think PHP is fine for daemons in some circumstances.
</blockquote>
<p>
The excerpt is mainly the first part of the chapter that just introduces the idea of daemons including some of the right and wrong uses, using the right tool for the job and how using PHP for a daemon can help with needs in a place where PHP might already be a norm.
</p>]]></description>
      <pubDate>Fri, 24 Sep 2010 12:39:17 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Content with Style: PHP worker processes with Beanstalk and Daemontools]]></title>
      <guid>http://www.phpdeveloper.org/news/14283</guid>
      <link>http://www.phpdeveloper.org/news/14283</link>
      <description><![CDATA[<p>
On the Content with Style blog there's a new post looking at <a href="http://www.contentwithstyle.co.uk/content/php-worker-processes-with-beanstalk-and-daemontools">creating a worker process</a> with PHP and the help of two other tools - <a href="http://kr.github.com/beanstalkd/">Beanstalkd</a> and <a href="http://cr.yp.to/daemontools.html">Daemontools</a>.
</p>
<blockquote>
Sometimes things just get too heavy for a straight forward approach. Memory usage might be too high or interaction might be delayed. In this case it might make sense to queue the task up for later execution. 
</blockquote>
<p>
The technique uses beanstalkd as a messaging queue to handle the requests based on the user's request via the interface the <a href="http://kr.github.com/beanstalkd/">beanstalkd library</a> provides. Then, to keep the queue running in the background and available, he uses daemotools to run a worker process. You can <a href="http://www.contentwithstyle.co.uk/resources/queue_test.zip">download the complete code</a> for a working example.
</p>]]></description>
      <pubDate>Thu, 01 Apr 2010 10:11:49 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Mark Karpeles' Blog: PHP DNS Daemon]]></title>
      <guid>http://www.phpdeveloper.org/news/11963</guid>
      <link>http://www.phpdeveloper.org/news/11963</link>
      <description><![CDATA[<p>
<i>Mark Karpeles</i> has created something that most people would think he's crazy for - a <a href="http://blog.magicaltux.net/2009/02/16/php-dns-daemon/">DNS daemon written in PHP</a>:
</p>
<blockquote>
If you want to tell me I'm crazy, you can post it in a comment here, it makes me happy. I had some reasons to dislike bind9 which finally made me write my own DNS daemon, and I'll explain that here. My need was to have a stable dynamic DNS server working in most environments, with an easy to configure master/slave relationship (with realtime synchronization), and a way to change records instantly from PHP...
</blockquote>
<p>
Rather than using the (slightly unstable) dlz technology to pull the information from a MySQL database, he opted to roll his own that includes support for:
</p>
<ul>
<li>RFC 1035 standards
<li>realtime data update
<li>slave/master relationship (with a keepalive connection)
</ul>
<p>
Want to try it out for yourself? <a href="mailto:mark@hell.ne.jp">Drop him a line</a> and ask about it!
</p>
<p>
He's also <a href="http://blog.magicaltux.net/2009/02/18/php-dns-daemon-performances/">run some statistics</a> on the performance of the daemon as compared to the standard BIND installation and <a href="http://blog.magicaltux.net/2009/02/19/your-own-php-dns-daemon/">come up with some instructions</a> on how you can install and configure your own instance.
</p>]]></description>
      <pubDate>Tue, 17 Feb 2009 12:06:24 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Mark Karpeles' Blog: proctitle: a new step for pinetd]]></title>
      <guid>http://www.phpdeveloper.org/news/11793</guid>
      <link>http://www.phpdeveloper.org/news/11793</link>
      <description><![CDATA[<p>
If you've ever worked with forking processes in PHP, you know things can get a little difficult when you have more than one process going at a time. Identification can become a hassle, especially if you need to kill one off because of performance issues. If you've found yourself in this spot before, you might want to check out <a href="http://blog.magicaltux.net/2009/01/21/proctitle-a-new-step-for-pinetd/">this update</a> <i>Mark Karpeles</i> has made to his <a href="http://www.pinetd.net/">pinetd</a> project to allow for naming of those forked processes.
</p>
<blockquote>
Ever wanted to give meaningful names to your processes when you pcntl_fork() with PHP ? proctitle is the extension you're looking for!
Adapted from <a href="http://bugs.php.net/29479">bug report #29479</a> and code initially wrote by <a href="http://en.wikipedia.org/wiki/User:Midom">Midom</a> for Wikipedia, the proctitle extension allows for a process to change its own displayed title in the system's process list.
</blockquote>
<p>
The extension (seen in action <a href="http://blog.magicaltux.net/wp-content/uploads/2009/01/viva_pinetd1.png">here</a>) is an interface for making different sorts of daemons, including the ability to give them names. You can check out the project <a href="http://ookoo.org/svn/proctitle/">here</a>.
</p>]]></description>
      <pubDate>Thu, 22 Jan 2009 11:12:17 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Kevin van Zonneveld's Blog: Create daemons in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/11717</guid>
      <link>http://www.phpdeveloper.org/news/11717</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Kevin van Zonneveld</i> talks about <a href="http://kevin.vanzonneveld.net/techblog/article/create_daemons_in_php/">making daemons</a>, backend scripts that run independent of a web server.
</p>
<blockquote>
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?
</blockquote>
<p>
He starts with a definition ("a linux program that runs in the background") and why PHP makes a good language choice for creating them. His example uses the <a href="http://pear.php.net/package/System_Daemon">System_Daemon</a> PEAR class to do most of the heavy lifting. To use it, you only need to include it at the top of the script and make two calls to the setOption and start methods to have the rest of the code all set to run as a daemon.
</p>
<p>
The example code sets up a daemon complete with support for command-line arguments and the ability to be run from init.d on the local system.
</p>]]></description>
      <pubDate>Mon, 12 Jan 2009 08:47:31 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[JSLabs Blog:  An ftp server written in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/7377</guid>
      <link>http://www.phpdeveloper.org/news/7377</link>
      <description><![CDATA[<p>
In a <a href="http://www.whenpenguinsattack.com/2007/03/05/an-ftp-server-written-in-php/">new post</a> to the JSLabs blog today, <i>Justin Silverton</i> mentions a FTP server that's been created entirely in PHP - <a href="http://www.jaslabs.com/downloads">nanoFTP</a>.
</p>
<blockquote>
nanoFTPd is an ftp daemon written in php. as of version 4.2.0, php supports the command-line interface (stable since 4.3.0), which nanoFTPd relies on. nanoFTPd is modular, so it's easy to add custom modules and other stuff, like different database interfaces (currently supports mysql and postgresql).
</blockquote>
<p>
Features of <a href="http://www.jaslabs.com/downloads">the app</a> include user authentication via a database or text file, dynamic IP support, and most of the usual FTP goodies you're used to in a server. You'll need at least PHP 4.2.0 to get it up and running, but configuration is simple and installations it just as easy. You can grab the software from <a href="http://www.jaslabs.com/downloads">their website</a>.
</p>]]></description>
      <pubDate>Mon, 05 Mar 2007 08:27:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Chris Chabot's Blog: phpSocketDaemon]]></title>
      <guid>http://www.phpdeveloper.org/news/6925</guid>
      <link>http://www.phpdeveloper.org/news/6925</link>
      <description><![CDATA[<p>
<i>Chris Chabot</i> <a href="http://www.chabotc.nl/phpsocketdaemon/">has posted</a> a PHP package he's worked up that functions as a daemon sitting and listening on a socket.
</p>
<blockquote>
To deal with 1000's of concurrent, always on (comet aka hanging iframe) http (server) connections, and an equal amount of IRC client connections, plus being able to interpret and parse and delegate all the messages and events, i needed a very fast, stable, flexible and easy to use 'daemon' library for PHP.
</blockquote>
<p>
He links to <a href="http://www.chabotc.nl/phpsocketdaemon-1.0/phpsocketdaemon-1.0.tar.gz">the tarball of the release</a> and to the <a href="http://code.google.com/p/phpsocketdaemon/">project page</a> as well as including an example of its usage - creating a simple HTTP server with various hooks built in (like on_connect, on_read, and on_timer).
</p>]]></description>
      <pubDate>Mon, 18 Dec 2006 18:08:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Managing Standalone Scripts in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/6222</guid>
      <link>http://www.phpdeveloper.org/news/6222</link>
      <description><![CDATA[<p>
DevShed continues their look at standalone PHP scripts (server-side scripting, not on the web) in <a href="http://www.devshed.com/c/a/PHP/Managing-Standalone-Scripts-in-PHP/">part two</a>, "Managing Standalone Scripts in PHP" excerpted from the book "Advanced PHP Programming" from <i>George Schlossnagle</i>.
</p>
<blockquote>
Last week, we began our discussion of PHP standalone scripts. This week, we'll be talking about child processes, shared resources, signals, and writing daemons.
</blockquote>
<p>
They <a href="http://www.devshed.com/c/a/PHP/Managing-Standalone-Scripts-in-PHP">jump right in</a>, going first for a look at forking off child processes from the script using the pcntl functionality you'll need to build into PHP. Resource management is key to working with server scripts, and they show you how to close them out when you're through. Next up is a brief look at the types of signals that you can send to the child processes, and some good rules to follow for writing daemons in PHP.
</p>]]></description>
      <pubDate>Thu, 07 Sep 2006 16:19:52 -0500</pubDate>
    </item>
  </channel>
</rss>

