Home

Awesome

Hipchat notifier

Build Status Latest Stable Version Total Downloads

Usage

Getting started with a Hello World example.

// Configuration.
$rooms = [
    [
        'room_id' => '1234',
        'auth_token' => '****',
    ],
];

// Create the required Guzzle client.
$client = new Guzzle\Http\Client;
$hipchat = new Hipchat\Notifier($client, $rooms);

// Send the notification.
$hipchat->notify('Hello world!');

If you would like to send notification to different rooms, add some to the array.

// Configuration.
$rooms = [
    'frontenders' => [
        'room_id' => '1234',
        'auth_token' => '****',
    ],
    'backenders' => [
        'room_id' => '5678',
        'auth_token' => '****',
    ],
];

// Create the required Guzzle client.
$client = new Guzzle\Http\Client;
$hipchat = new Hipchat\Notifier($client, $rooms);

// Send the notification.
$hipchat->notifyIn('frontenders', 'Hello world!');

The default room in which the notify method posts to is the first from the array, or you can specify which room to use as a default with a third constructor parameter:

Extra configuration.

The constructor accepts a third parameter with extra options.

$config = [
    'default' => 'frontenders',
    'color' => 'gray',
    'pretend' => true,
    'notify' => true,
];

Color

Choose your color depending on the type of message with the second and third parameter of the notify and notifyIn method.

// Example 1
$color = $error ? 'red' : 'green';
$hipchat->notify($message, $color);

// Example 2
$hipchat->notifyIn('frontenders', $message, 'purple');

Laravel 4

This package comes with a Laravel 4 service provider. Add the following line to the providers array in app.php.

'Hipchat\Support\ServiceProvider',

It also registers an alias for the Facade class Hipchat\Support\Facades\Hipchat so you can just use Hipchat::notify($message) and Hipchat::notifyIn('frontenders', $message).

Publish the default configuration with the following command:

php artisan config:publish hannesvdvreken/hipchat

All configurable options can be found there.

Contributing

Feel free to make a pull request. Please try to be as PSR-2 compliant as possible.

License

MIT