, (*1)
Usage
Getting started with a Hello World example., (*2)
// 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., (*3)
// 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:, (*4)
The constructor accepts a third parameter with extra options., (*5)
$config = [
'default' => 'frontenders',
'color' => 'gray',
'pretend' => true,
'notify' => true,
];
-
default
: The default room to send notifications in with ->notify()
.
-
color
: Choose from yellow
, red
, green
, purple
, gray
or random
.
-
pretend
: Don't actually send any messages.
-
notify
: Let hipchat make a sound.
Color
Choose your color depending on the type of message with the second and third parameter of the
notify
and notifyIn
method., (*6)
// 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
., (*7)
'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)
., (*8)
Publish the default configuration with the following command:, (*9)
php artisan config:publish hannesvdvreken/hipchat
All configurable options can be found there., (*10)
Contributing
Feel free to make a pull request. Please try to be as
PSR-2
compliant as possible., (*11)
License
MIT, (*12)