承接 nycu-csit/laravel-mattermost 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nycu-csit/laravel-mattermost

最新稳定版本:v0.1.0

Composer 安装命令:

composer require nycu-csit/laravel-mattermost

包简介

Mattermost Notification Channel for Laravel

README 文档

README

This package provides the custom Mattermost Notification Channel for Laravel 10+ applications.

Installation

Add following lines to your composer.json:

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/nycu-csit/laravel-mattermost"
    }
],
"require": {
    "nycu-csit/laravel-mattermost": "^0.1.0"
}

Usage

  1. Add Mattermost config in the services.php

    // services.php
    'mattermost' => [
        'webhook_url' => env('MATTERMOST_WEBHOOK_URL'),
    ],
  2. Use MattermostChannel in via method, and define toMattermost method which should return an instance of MattermostMessage. You can return falsy value from that method to not send the message to Mattermost.

    <?php
    
    namespace App\Notifications;
    
    use NycuCsit\LaravelMattermost\MattermostChannel;
    use NycuCsit\LaravelMattermost\MattermostMessage;
    use Illuminate\Bus\Queueable;
    use Illuminate\Notifications\Notification;
    
    class NotifyMeetingStartEnd extends Notification
    {
        use Queueable;
    
        public function __construct(private Meeting $meeting)
        {
        }
        /**
        * Get the notification channels.
        */
        public function via(object $notifiable)
        {
            return [MattermostChannel::class];
        }
    
        /**
        * Get the payload of the mattermost webhook.
        * See on the [official website](https://developers.mattermost.com/integrate/webhooks/incoming/#parameters).
        * 
        * Notification can exit early without actually sending to Mattermost
        * channel by returning from falsy value.
        */
        public function toMattermost(object $notifiable)
        {
            // exit early
            if ($this->meeting->started) {
                return null;
            }
            // https://developers.mattermost.com/integrate/webhooks/incoming/#parameters
            return (new MattermostMessage)
                ->text('...')
                ->channel('town-square');
        }
    }

Testing

./vendor/bin/phpunit

统计信息

  • 总下载量: 87
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-05