承接 ohffs/laravel-msteams-alerts 相关项目开发

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

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

ohffs/laravel-msteams-alerts

最新稳定版本:1.3.0

Composer 安装命令:

composer require ohffs/laravel-msteams-alerts

包简介

Send a message to MS Teams

README 文档

README

This package can quickly send alerts to Microsoft Teams. You can use this to notify yourself of any noteworthy events happening in your Laravel app. This is a fork of Spatie's laravel-slack-alerts so all thanks to them for doing the main bulk of the work. I've pretty much just changed 'Slack' to 'MSTeams'.

use Ohffs\MSTeamsAlerts\Facades\MSTeamsAlert;

MSTeamsAlert::message("You have a new subscriber to the {$newsletter->name} newsletter!");

Under the hood, a job is used to communicate with MS Teams. This prevents your app from failing in case Teams is down.

Want to send alerts to Discord or Slack instead? Check out laravel-discord-alerts and laravel-slack-alerts.

Installation

You can install the package via composer:

composer require ohffs/laravel-msteams-alerts

You can set a MSTEAMS_ALERT_WEBHOOK env variable containing a valid Teams webhook URL. You can learn how to get a webhook URL in the Teams docs.

Alternatively, you can publish the config file with:

php artisan vendor:publish --tag="msteams-alerts-config"

This is the contents of the published config file:

return [
    /*
     * The webhook URLs that we'll use to send a message to Teams.
     */
    'webhook_urls' => [
        'default' => env('MSTEAMS_ALERT_WEBHOOK'),
    ],

    /*
     * This job will send the message to Teams. You can extend this
     * job to set timeouts, retries, etc...
     */
    'job' => Ohffs\MSTeamsAlerts\Jobs\SendToMSTeamsChannelJob::class,
];

Usage

To send a message to Teams, simply call MSTeamsAlert::message() and pass it any message you want.

MSTeamsAlert::message("You have a new subscriber to the {$newsletter->name} newsletter!");

Using multiple webhooks

You can also use an alternative webhook, by specify extra ones in the config file.

// in config/msteams-alerts.php

'webhook_urls' => [
    'default' => 'https://hooks.office.com/services/XXXXXX',
    'marketing' => 'https://hooks.office.com/services/YYYYYY',
],

The webhook to be used can be chosen using the to function.

use Ohffs\MSTeamsAlerts\Facades\MSTeamsAlert;

MSTeamsAlert::to('marketing')->message("You have a new subscriber to the {$newsletter->name} newsletter!");

Using a custom webhooks

The to function also supports custom webhook urls.

use Ohffs\MSTeamsAlerts\Facades\MSTeamsAlert;

MSTeamsAlert::to('https://custom-url.com')->message("You have a new subscriber to the {$newsletter->name} newsletter!");

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固