ميزانور/hipchat-notifier

Hipchat Notifier for PHP

v1.2 2017-04-10 08:34 UTC

This package is not auto-updated.

Last update: 2024-09-14 22:46:26 UTC


README

Super-simple, minimum abstraction HipchatNotifier v2, in PHP.

需要PHP 5.3和一个脉冲。

安装

您可以使用Composer安装hipchat-notifier

composer require mizanur/hipchat-notifier

composer require mizanur/hipchat-notifier

如何使用

您可以使用.env文件开始,也可以不使用.env文件

使用.env

我们需要在.env文件中设置一些配置变量

HIPCHAT_DOMAIN=https://example.hipchat.com
HIPCHAT_TOKEN=your-room-token
HIPCHAT_ROOM_ID=your-room-id
HIPCHAT_BOT_NAME=your-bot-name (this one is optional, default bot name is HIP-BOT)

初始化hipchat notifier

$hipchatNotifier = new \HipchatNotifier\HipchatNotifier();

不使用.env

初始化hipchat notifier

//the last param bot-name is optional, default bot name is HIP-BOT

$hipchatNotifier = new \HipchatNotifier\HipchatNotifier('YOUR-DOMAIN','YOUR-ROOM-ID','YOUR-ROOM-TOKEN', 'BOT-NAME');

向您的hipchat房间发送错误通知

//you can pass your color as second param (red or green or yellow) default is red

$hipchatNotifier->notifyError('YOUR ERROR MESSAGE');

//or

$hipchatNotifier->notifyError('YOUR ERROR MESSAGE', 'green');

向您的hipchat房间发送成功或信息通知

//you can pass your color as second param (red or green or yellow) default is green

$hipchatNotifier->notifyInfo('YOUR MESSAGE');

//or

$hipchatNotifier->notifyInfo('YOUR MESSAGE', 'red');

向您的hipchat房间发送异常通知

//you can pass your color as second param (red or green or yellow) default is red

try{
    #Your code...
}catch(\Exception $ex){
    $hipchatNotifier->notifyException($ex);
}

//or

try{
    #Your code...
}catch(\Exception $ex){
    $hipchatNotifier->notifyException($ex, 'yellow');
}