PHP

Obtaining JUnit-compatible XML from SimpleTest

SimpleTest is a nice testing framework for testing PHP-based applications at the unit and functional level. However, I (and others) have had trouble getting JUnit-compatible XML output for use in continuous integration servers like Jenkins.

SimpleTest provides a built-in XML-based output, but it seems to be mostly for internal communication by SimpleTest itself. It's not JUnit compatible.

To convert SimpleTest output into JUnit-compatible XML, I've seen at least a few posts :

SimpleTest vs. PHPUnit for PHP-based testing

Over the year's I've kind of gone back and forth on SimpleTest, a PHP-based unit test framework.

A few years ago, when PHPUnit was in its infancy, SimpleTest was the best PHP-based unit test framework. In the past few years, however, it seems like PHPUnit has been improved continually, while SimpleTest has languished somewhat.

Currently, I believe PHPUnit is the best choice for true "unit" ("micro") testing, while SimpleTest seems to be better for modest functional (integration) testing.

HTML Tidy options in PHP context

<?php

// http://tidy.sourceforge.net/docs/quickref.html#add-xml-decl

$tidyOpts = array(
// 'bare' => TRUE, // strip MS HTML
// 'clean' => TRUE, // strip presentational tags
// 'css-prefix' => 'calc-', // CSS prefix for styles - default 'c'
// 'doctype' => 'omit', // DOCTYPE for output
// 'drop-empty-paras' => TRUE,
// 'drop-font-tags' => TRUE, // drop and with no corresponding style rules
// 'drop-proprietary-attributes' => TRUE, // drop things like MS data binding attributes

Categories: 

PHP-oriented job or queue manager

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'

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 :

Categories: 

Installing PHP's Testing_Selenium on Windows

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 :

Categories: 

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

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.

Categories: 

Cheap PHP lint checking with Git

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 :

    Categories: 

    Setting up Custom Coding Standards with PHP CodeSniffer

    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.

    Categories: 

    Installing Hudson, Phing, PHPUnit and Git on Ubuntu

    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  

    Pages

    Subscribe to RSS - PHP