Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kayw-geek/yii2-error-dingtalk
🔥When an HTTP error occurs, it can help you record the log and notify the Dingding group through webhook
https://github.com/kayw-geek/yii2-error-dingtalk
dingtalk error-handling notify yii2 yii2-extension
Last synced: about 10 hours ago
JSON representation
🔥When an HTTP error occurs, it can help you record the log and notify the Dingding group through webhook
- Host: GitHub
- URL: https://github.com/kayw-geek/yii2-error-dingtalk
- Owner: kayw-geek
- License: mit
- Created: 2020-09-09T06:49:12.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-17T05:40:11.000Z (about 4 years ago)
- Last Synced: 2024-09-23T22:31:22.547Z (4 days ago)
- Topics: dingtalk, error-handling, notify, yii2, yii2-extension
- Language: PHP
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# :fire: Yii2 Error DingTalk
[![JavaScript Style Guide: Good Parts](https://img.shields.io/badge/code%20style-goodparts-brightgreen.svg?style=flat)](https://github.com/kayw-geek/yii2-error-dingtalk "JavaScript The Good Parts")[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FKay-Wei%2Fyii2-error-dingtalk.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fkayw-geek%2Fyii2-error-dingtalk?ref=badge_shield)![](https://img.shields.io/github/languages/code-size/kayw-geek/yii2-error-dingtalk)
基于Yii2错误处理的钉钉群机器人Webhook通知
## 安装
使用 Composer 安装:
```
$ composer require kayw-geek/yii2-error-dingtalk
```## 使用
1. 入口文件 `index.php` 中 `defined('YII_DEBUG') or define('YII_DEBUG', true);` 修改为 `defined('YII_DEBUG') or define('YII_DEBUG', false);`
2. 确保应用下 main.php 配置文件中已配置
```php
'errorHandler' => [
'errorAction' => 'site/error',
],
```3. SiteController控制器中配置
```php
public function actions()
{
return [
'error' => [
'class' => 'kaywGeek\yii2ErrorDingtalk\ErrorDingtalk',
'handle' => [ '500','403','401','502','404'], //启用哪些状态码
'title' => 'PC Web 异常状态码监测通知', //通知标题
'logCategoryName' => 'error-status', //日志分类名
'dingTalkWebHookUrl' => 'https://oapi.dingtalk.com/robot/send?access_token=xxxxxx', //钉钉群机器人获取到的webhook URL
'enable' => true, //是否启用
'text'=>'- 用户IP: '.Yii::$app->request->userIP, //设置额外的通知内容],
];
}
```## 获取钉钉机器人Webhook URL
点击自己的钉钉群 - 群设置 - 智能群助手 - 群机器人 - 添加机器人 - 获取Webhook 地址
**注意: 安全设置可以选择自定义关键词 通知内容中只要包含 设置的关键词 就可以正常推送**
## 效果展示
![](https://s1.ax1x.com/2020/09/10/wJAqun.png)
# License
[![alt text](https://app.fossa.io/api/projects/git%2Bgithub.com%2FKay-Wei%2Fyii2-error-dingtalk.svg?type=large "License")](https://app.fossa.io/projects/git%2Bgithub.com%2FKay-Wei%2Fyii2-error-dingtalk?ref=badge_large)