Net_Growl Advanced UDP usage
============================
include::../revision.txt[]

Source Code
-----------

[source,php,numbered]
----
<?php
/**
 * Example that send notifications to Growl about PEAR Errors
 *
 * PHP version 5
 *
 * @category Networking
 * @package  Net_Growl
 * @author   Laurent Laville <pear@laurent-laville.org>
 * @author   Bertrand Mansion <bmansion@mamasam.com>
 * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
 * @version  CVS: Release: 2.1.1
 * @link     http://growl.laurent-laville.org/
 * @since    File available since Release 2.0.0RC2
 */

require_once 'Net/Growl.php';
require_once 'PEAR.php';

// Notification Type definitions
define('GROWL_NOTIFY_PEARERROR', 'PEAR_Error');

/**
 * PEAR_Error callback function
 *
 * @param object $error PEAR_Error instance
 *
 * @return void
 */
function growlErrors($error)
{
    static $app;

    if (!isset($app)) {
        $app = new Net_Growl_Application(
            'Net_Growl', array(GROWL_NOTIFY_PEARERROR), 'mamasam'
        );
    }

    $growl = Net_Growl::singleton(
        $app, null, null, array('host' => '192.168.1.2')
    );
    $growl->notify(
        GROWL_NOTIFY_PEARERROR,
        get_class($error),
        $error->message.' in '.$_SERVER['SCRIPT_NAME'],
        array('sticky' => true)
    );
}

PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'growlErrors');

PEAR::raiseError("The expected error you submitted does not exist");
?>
----
