wangchengtao/laravel-exception-notify

laravel 框架适配异常监控通知, 支持钉钉群机器人, 飞书群机器人以及自定义通道

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/wangchengtao/laravel-exception-notify

v1.0.7 2026-01-04 08:00 UTC

This package is auto-updated.

Last update: 2026-01-04 08:31:01 UTC


README

功能

  • 支持多种通道(钉钉群机器人 飞书群机器人 企业微信群机器人)
  • 支持扩展自定义通道

环境要求

  • laravel >= 6.0

安装

composer require wangchengtao/laravel-exception-notify

配置

  1. 创建配置文件:
php artisan vendor:publish --provider="Summer\LaravelExceptionNotify\ExceptionNotifyServiceProvider"

使用

use Summer\ExceptionNotify\Message\Dingtalk\DingtalkMarkdown;
use Summer\LaravelExceptionNotify\Notify;

// 文本格式
$text = new DingtalkText();
$text->setTitle('测试');
$text->setContent('异常测试');
$text->setAt([
    '187*****897',
]);

Notify::send($text);

// markdown 格式
$markdown = new DingtalkMarkdown();
$markdown->setTitle('Markdown消息标题');
$markdown->setContent("#### 这是Markdown消息内容 \n ![图片](https://example.com/image.png)");
$markdown->atAll();

Notify::send($markdown);

效果图

效果图 效果图

自定义通道

  • 所有自定义通道继承自 AbstractChannel
  • 所有自定义消息继承自 AbstractMessage
use Summer\ExceptionNotify\Channel\AbstractChannel;
use Summer\ExceptionNotify\Message\AbstractMessage;
use Summer\LaravelExceptionNotify\Notify;

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('自定义消息');

Notify::channel(CustomChannel::class)->send($message);