 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Kurt Payne's Blog: How to Unit Test pcntl_fork()
by Chris Cornutt January 19, 2012 @ 13:40:20
Kurt Payne has a new post to his blog showing how you can unit test your process forking in your PHP application (pcntl).
At some point, many php developers turn to the pcntl functions in php to write a daemon, or server, or simulate threading. But how do you unit test this with complete code coverage? [...] We need to engage some black arts php extensions to make this happen. An installation guide follows, and the post ends with a complete listing of the unit test.
He uses the test_helpers extension (as provided by Sebastian Bergmann) and Runkit to allow the test to define new methods copying the current pcntl methods and mocks up the responses. Tests are included to check the parent of a process, checking the children of a process and testing that a fork could be made. Hes's even included visual proof of this working.
voice your opinion now!
unittest pcntl pcntlfork testhelper runkit mock
Brian Moon's Blog: Forking PHP!
by Chris Cornutt July 24, 2009 @ 09:25:18
In a new post from Brian Moon looking at how they're (DealNews) using forking in PHP applications to handle some of their Gearman processing.
While at the OReilly Open Source Convention in 2009, we were asked about how we pulled this off. So, we are releasing the two scripts that handle the forking and some instructions on how we use them. [...] These are the scripts we use to manage long running processes. They work great for us on Linux. They will not run on Windows at all. We also never had any trouble running them on Mac OS X.
The two scripts (that you can grab on their developer site) show two methods for running child processes and how to pass off requests to each one to be handled in turn.
voice your opinion now!
pcntl fork process
Developer Tutorials Blog: Running background processes in PHP
by Chris Cornutt July 18, 2008 @ 11:18:21
New on the Developer Tutorials blog today is this look at handling background processes from your PHP script:
You've checked and double checked the integrity of user input, and you're doing some serious processing. There's only one problem: it's too slow. There's a simple solution: forking your processing script, and running the code as a background process asynchronously. It can email your user when it's done: they'll wait. In this tutorial, I'll show you how to get started with background processes in PHP.
Akash gives examples of the three keys to background processes - starting the script via an exec, talking to the process by passing additional parameters and including code to monitor the state of the background process via something like a MySQL "sessions" table that the script writes to.
voice your opinion now!
process background exec parameter mysql session track
Nessa's Blog: Using PHP to Display Version Info (I and II)
by Chris Cornutt October 19, 2007 @ 11:23:00
Nessa has two posts that talk about how to use PHP to display the versions of software running on the local machine.
I've been working on this application for work that does some simple server reporting, part of which involves displaying the versions of major software running on the machines. [...] I need to be aware of this to make sure that customers are being moved to servers with compatible versions. It's also good in tracking and planning upgrades.
In the first post she recommends using the exec function in PHP to run system commands to get things like the cpanel version, python version and what perl you have installed.
Part two shows a little bit different way to get some of the same information - using the data in the /proc/version file as a single resource to get OS information.
voice your opinion now!
display version information exec proc version file display version information exec proc version file
|
Community Events
Don't see your event here? Let us know!
|