PHP

PHP-oriented job or queue manager

Posted on June 18th, 2010 by David Luhman and tagged , , , .

I'm looking for a way to manage asynchronous, potentially long-running PHP jobs (ex. feed import and generation). One could start with a simple cron-based system, but this has a few drawbacks :

  • Too much 'downtime' if you set the sample interval too long
  • Overlapping jobs if jobs don't finish
  • No ability to handle events or dependency issues

I've previously used AppWorx (appworx.com) in a large ETL operation. AppWorx is quite sophisticated with a distributed slave architecture, chains, forks and joins. But AppWorx is probably too complex for my needs.

Facebook releases 'HipHop' - a PHP 'compiler'

Posted on March 5th, 2010 by David Luhman and tagged .

I stumbled across something called 'HipHop' from Facebook :

Here is how Sebastian Bergmann describes it :

"HipHop for PHP" is a source code transformer that turns PHP 5.2 code (minus some features) into C++ code that can then be compiled with g++, for instance, to a regular binary.

Since much of the Facebook front-end is written in PHP, they found HipHop necessary to reduce their need for servers.

Here are a couple articles on this :

Installing PHP's Testing_Selenium on Windows

Posted on February 25th, 2010 by David Luhman and tagged , .

Earlier I blogged about setting up Selenium, PHPUnit et al on an Ubuntu machine.

Although I prefer to do web development on an Ubuntu machine, for 'legacy' reasons I still do some stuff on a Windows machine. For lighter web interface testing, a full CI tool like Hudson is overkill. Here's how to run Pear's Selenium_Testing alone (without PHPUnit) on Windows.

I assume you have PHP and the Pear installer on your Windows machine. Grab the Pear Selenium_Testing package with :

Writing a simple OO template system in PHP to separate logic and presentation

Posted on February 21st, 2010 by David Luhman and tagged .

If you're maintaining a legacy PHP application which suffers from mixing of application logic and presentation, you may want to implement a simple template system to help separate these two.

Of course there are plenty of existing PHP templating systems, with Smarty being one of the most 'notorious' ;-). But if you have simple needs and don't want to introduce external dependencies to your code, rolling your own simple system can make sense. Let's face it -- you can often roll your own in the time it takes to figure out someone else's system.

Cheap PHP lint checking with Git

Posted on February 12th, 2010 by David Luhman and tagged , .

Running PHP's "built-in" lint checker (php -l) is a quick way to remove syntax errors which should never creep into your code.

However, you'll no doubt soon tire of typing "php -l" before every Git commit message, so why not let Git do the checking for you with a "pre-commit hook".

Travis Swicegood has a great article on how to set this up with Git :
http://phpadvent.org/2008/dont-commit-that-error-by-travis-swicegood

I found you could pretty much copy his pre-commit PHP script and paste it into your .git/hooks directory with a couple caveats :

Setting up Custom Coding Standards with PHP CodeSniffer

Posted on December 17th, 2009 by David Luhman and tagged , .

PHP CodeSniffer provides you with some useful coding standards to get you going.

This is nice, but how do you customize what's provided or set up your own standards?

There is a tutorial on how to set up your own standards, but that was too much work for me at the moment.

However, that is NOT the way to set up your own standards, in my opinion.

Installing Hudson, Phing, PHPUnit and Git on Ubuntu

Posted on December 15th, 2009 by David Luhman and tagged , , , .

In this post, I'm just trying to get the simplest setup. I'll try to post details in a subsequent post.

Here are three posts, in descending order, on this that I found useful :

http://toptopic.wordpress.com/2009/02/26/php-and-hudson/

http://blog.jepamedia.org/2009/10/28/continuous-integration-for-php-with...

http://www.davegardner.me.uk/blog/2009/11/09/continuous-integration-for-...

First, I had to install java :

    $ sudo aptitude install sun-java6-jre  

PHP client-side GUI programming - PHP-GTK

Posted on November 17th, 2009 by David Luhman and tagged .

I've been running CLI-based PHP scripts for scripting and more complex "applications" since the CLI was introduced back in PHP 4.3. As time has gone along, the applications have become more complex and varied. I only use some of these applications every few months, so it's easy to forget how to run the application without the guidance provided by a GUI.

For quite some time I've been looking for something along the lines of HyperCard whereby I can put together a simple GUI without too much work; however, this would be in the context of my existing PHP scripts.

Installing PHP-GTK on Windows

Posted on November 14th, 2009 by David Luhman and tagged , .

Installing PHP-GTK

Installing recent (as of Nov 2009) versions of PHP-GTK seems to be a little tricky. If you want to have PHP-GTK, Glade support, and MySQL support, it looks like you need to download and merge THREE different downloads.

Quick and dirty PHP debugging

Posted on June 15th, 2009 by David Luhman and tagged .

Xdebug (http://xdebug.org) is probably one of the best ways to debug PHP code. But Xdebug can be difficult to setup, depending on the environment.

Here's a quick and dirty method to see a select list of PHP variables. This was lifted from the notes at http://php.net/manual/en/function.get-defined-vars.php.


    function getDefinedVars($varList, $excludeList) {
        $temp1 = array_values(array_diff(array_keys($varList), $excludeList));
        $temp2 = array();
        while (list($key, $value) = each($temp1)) {
            global $$value;