2022-10-27 08:30:53 +00:00
|
|
|
## 三方平台消息通知组件
|
|
|
|
|
|
|
|
## 功能
|
|
|
|
|
|
|
|
* 支持钉钉群机器人、飞书群机器人、企业微信群机器人
|
|
|
|
* 支持扩展自定义通道&消息模板
|
|
|
|
|
|
|
|
## 环境要求
|
|
|
|
|
|
|
|
* hyperf >= 2.2
|
|
|
|
|
|
|
|
## 安装
|
|
|
|
|
2022-10-27 09:08:10 +00:00
|
|
|
### 设置仓库
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"repositories": [{
|
|
|
|
"type": "composer",
|
|
|
|
"url": "http://192.168.21.189"
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
2022-10-27 08:30:53 +00:00
|
|
|
```sh
|
|
|
|
composer require tm-wms/message-notify
|
|
|
|
```
|
|
|
|
|
|
|
|
## 配置文件
|
|
|
|
|
2022-12-08 09:05:25 +00:00
|
|
|
发布配置文件`config/message_notify.php` 具体配置message_notify.php
|
2022-10-27 08:30:53 +00:00
|
|
|
|
|
|
|
```sh
|
|
|
|
php bin/hyperf.php vendor:publish tm-wms/message-notify
|
|
|
|
```
|
|
|
|
|
|
|
|
## 使用
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
use TmWms\MessageNotify\Notify;
|
|
|
|
use TmWms\MessageNotify\Channel\DingTalkChannel;
|
|
|
|
use TmWms\MessageNotify\Template\Text\DingTalk;
|
|
|
|
|
|
|
|
// 初始通道
|
|
|
|
$channel = new DingTalkChannel();
|
|
|
|
|
|
|
|
// 初始消息模板
|
|
|
|
$template = (new DingTalk())
|
|
|
|
->setTitle('test')
|
|
|
|
->setText('test')
|
|
|
|
//@所有人
|
|
|
|
->setAt([
|
|
|
|
'all'
|
|
|
|
]);
|
|
|
|
|
|
|
|
// 发送
|
|
|
|
Notify::make($channel)->send($template);
|
|
|
|
|
|
|
|
```
|
|
|
|
|