It’s far from rocket science, but this small extension I wrote over the Holidays allows PHP to send messages to the Snarl Notification Tool. Snarl was inspired by Growl for Mac OS and despite it’s reliance on a C/C++ API (versus a network API as with Growl) isn’t too hard to work with.

My intention for the API is to facilitate Window’s use of a soon to be announced tool for autotesting in PHP using PHPSpec. The basic idea is that rather then switching to a console to rerun selected tests or specs for each change a developer makes, a behind the scenes PHP process automatically detects modifications to files and reruns only selected tests/specs relevant for those files, and reports results in a notification popup. The difference between this and the usual method is really simple – by avoiding switching to the console and/or running all specs including those unrelated to the change (which feasibly can take anything from a few seconds to a few minutes), you can shave time off your development process. In a nutshell, in many cases it’s just more efficient and stays out of your way.

I hope to propose a completed version of the extension to PECL shortly. For the moment I’ve only implemented a single method to display a timed notification of some event. Obviously the extension itself is not specific to PHPSpec use – anywhere PHP would be useful in creating a desktop notification on Windows.

The source code is currently in subversion at http://code.google.com/p/php-snarl/ on Google Code.

I haven’t uploaded a compiled .dll extension yet but I’ll get around to it soon. Usage will be relatively simple. The extension defines a PHP5 class called (predictably) Snarl:

[geshi lang=php]
$snarl = new Snarl;
$snarl->showMessage(‘Title’, ‘Notice! Your PC is about to explode!’, 5, ‘C:/icons/warning.png’);
[/geshi]There’s other parts to the Snarl API but showing timed notice messages is the most common use case. It’s likely PHPSpec will in the future bundle similar dependencies for Mac OS Growl and KDE Notify (possibly depending on its API for KDE4) as part of a small abstraction library to make use across platforms easier.

Related posts:

  1. PHPSpec Reporting Gets A Needed Boost
  2. Ruby Testing Tools Missing From PHP
  3. PHPMock: Independent Mock Object/Stub Framework
  4. Mutation Testing Brain Dump
  5. Compiling PHP for Windows Vista using Visual C++ Express 2008 – Seriously!