wangchengtao / exception-notify
异常监控, 支持钉钉群机器人,飞书群机器人,企业微信群机器人, 以及自定义通道
Installs: 3
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/wangchengtao/exception-notify
Requires
- php: >=7.2
- guzzlehttp/guzzle: ^6.5 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2025-12-17 08:22:32 UTC
README
功能
- 支持多种通道(钉钉群机器人 飞书群机器人 企业微信群机器人)
- 支持扩展自定义通道
环境要求
- php: >= 7.2
安装
composer require wangchengtao/exception-notify
使用
$channel = new Dingtalk([ 'access_token' => 'xxxxxxxxxxxxx', 'auth_type' => 'sign', // 安全设置类型: keyword | sign 'keyword' => '异常', // 当 auth_type 为 keyword 时,必填 'secret' => 'xxxxxxxxxxxxxxxxxxxx', // 当 auth_type 为 sign 时,必填 'at' => [], // 当 message 对象未指定@人员时,此为默认值 ]); $client = new Client($channel); $text = new DingtalkText(); $text->setTitle('测试'); $text->setContent('异常测试'); $text->setAt([ '187*****897', ]); $client->send($text);
效果图
自定义通道
- 所有自定义通道继承自
AbstractChannel - 所有自定义消息继承自
AbstractMessage
use Summer\ExceptionNotify\Channel\AbstractChannel; use Summer\ExceptionNotify\Message\AbstractMessage; class CustomChannel extends AbstractChannel { public function handleResponse(ResponseInterface $response): void { // TODO: Implement getBody() method. } public function send(string $content): ResponseInterface { // TODO: Implement getBody() method. } } class CustomMessage extends AbstractMessage { public function getBody() : array { // TODO: Implement getBody() method. } } $message = new CustomMessage(); $message->setTitle('自定义标题'); $message->setContent('自定义消息'); $channel = new CustomChannel([ 'access_token' => 'xxxxxxxxxxxxx', ]); $client = new Client($channel); $client->send($text);
