Make PHP Growl
. . . but in a good way!

I stumbled upon a fantastic PHP class today and felt compelled to comment on it. Originally written by Tyler Hall, this class allows you to send notifications to any system running Growl from a PHP script. For those of you that don't know, Growl is an application written for Mac OS X that is intended to act as a universal notification tool (much like the taskbar notification bubbles we've all come to know and love in Windows XP/Vista).
The class itself is incredibly simple and straightforward, and allows you to send notifications using only 5 lines of code. Consider this simple example:
// Setup
$growl = new Growl();
$growl->setAddress('127.0.0.1');
$growl->addNotification("Test");
$growl->register();
// Send Notification
$growl->notify("Test", "Test Alert", "The body of the test alert!");Pretty nifty isn't it? One could very easily integrate this into a logger to notify you immediately of any critical errors with your scripts, or even tell you every time a given page is viewed. So if you want to check out my modified version (a bit more standards-compliant with PHP 5) you can see it here, or view the original author's site to see the original.
Download: Growl PHP Class



I assume that the address of 127.0.0.1 could be set to any ip/address? This could be amazingly handy when it comes to debugging ajax scripts and things which have no real output.
I could imagine some fun uses for this! I bet that could integrate well with the new jabber ajax client (link below). http://sourceforge.net/project/screenshots.php?group_id=220605
Left by Paul | Mar. 26, 2008 at 1:49pm
Absolutely - I should have mentioned that as well. You can specify virtually any type of valid network address (IP addresses, domains, and if you're on a local network computer names can be used as well). I imagine there are things I haven't even thought of that this could be used for - it should be fun to play with.
Left by Nick at SC | Mar. 26, 2008 at 3:04pm
Hey, Nick. Thanks for the great write-up. Definitely let me know if you run into any issues with the code.
Left by Tyler | Mar. 26, 2008 at 3:41pm
Thanks Tyler - as simple as it is, you've created something incredibly useful. Congrats and thanks for sharing!
Left by Nick at SC | Mar. 26, 2008 at 4:00pm
Thanks, didn't know about this one!
@Paul: Take a look at the firebug addon for firefox! Saved my life.
Left by kvz | Mar. 27, 2008 at 12:32am
Just for those that might not be able to see this working, in your Growl preferences you need to enable it to listen for incoming connections on the network and allow remote application registration (this wasn't set as default for my install)
Left by Scrivna | Mar. 27, 2008 at 2:31am
Ahh very cool! Never heard of it, thanks!
Left by Menekali | Mar. 27, 2008 at 1:31pm
Im already drewling, this one will be so fun
Left by mijako | Apr. 4, 2008 at 2:29am
I must admit I would never have thought of this idea! Can't wait to give it a go.. Great stuff
Left by Colin Miller - Freelance web designer | May. 29, 2008 at 3:59pm
I'd really like to give your PHP5 code a shot, but the download link appears to be broken!
Left by Aaron | Sep. 4, 2008 at 3:02pm
Thanks for the heads up Aaron, looks like it was a casualty from our latest site update. The link should be working now.
Left by Nick at SC | Sep. 17, 2008 at 11:06am
We've been trying to send Growl notifications from our own machines back to our own machines using 127.0.0.1, localhost, local IPs and external IPs but none of them have worked. We eventually tried sending a notification across the internet between two different machines and it worked. Anyone else had this problem? BTW - The PHP 5 link doesn't work.
Left by Alistair Holt | Oct. 26, 2008 at 6:33am
This is totally awesome. I love it. Just thinking of useful things I will use it for.
Left by kinoli | Dec. 30, 2008 at 9:37pm
Thanks a bunch!
I hope it is cool with you for me to integrate this into my Asteristickies application ( http://geekhut.org/asterisk-stickies/ )
There have been a lot of requests on IRC as well as many forums for easy Growl notifications for asterisk. This script makes my life VERY easy.
Much appreciated!
Left by aster1sk | Apr. 1, 2009 at 2:10am
hi Nick
Great script!!! thx alot.
I'm using this script to monitor all out server and pc's on campus. but is there a way to use custom icons on the notification?
Left by Quintin | May. 8, 2009 at 2:49am
amazing! automate my internet life.
Left by xmoov | May. 25, 2009 at 11:38am
Leave a Comment