Package Data | |
---|---|
Maintainer Username: | sebbmeyer |
Maintainer Contact: | sebbmyr@gmail.com (Sebastian Meyer) |
Package Create Date: | 2018-07-30 |
Package Last Update: | 2024-04-02 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-17 03:06:55 |
Package Statistics | |
---|---|
Total Downloads: | 133,231 |
Monthly Downloads: | 1,864 |
Daily Downloads: | 60 |
Total Stars: | 32 |
Total Watchers: | 5 |
Total Forks: | 10 |
Total Open Issues: | 2 |
A Laravel 5/6 package to send notifications to Microsoft Teams by using "Incoming Webhook". This package also contains a card to send a Laravel Forge deployment notification, because Microsoft Teams notification is not supported at the moment. The cards in this package only use the old MessageCard format, because AdpativeCard is not supported by Microsoft Teams at the moment. I will update the card format, when AdpativeCard format is supported.
If you are using Laravel 5.4 or older versions of laravel, please use the version 0.3.x of this package.
You can install the package via composer:
composer require sebbmeyer/laravel-teams-connector
If you are using Laravel 5.5 and up, the service provider will automatically get registered.
For older versions of Laravel (<5.5), you have to add the service provider and alias to config/app.php:
Sebbmyr\LaravelTeams\TeamsConnectorServiceProvider::class,
You can optionally use the facade for shorter code. Add this to your facades:
'TeamsConnector' => Sebbmyr\LaravelTeams\Facades\TeamsConnector::class,
For Lumen usage, the service provider should be registered manually by adding the following line in bootstrap/app.php
:
$app->register(Sebbmyr\LaravelTeams\TeamsConnectorServiceProvider::class);
For this package to work, you need to configure an "Incomming Webhook" connector in your targeted Teams channel and copy the url into a config file that you can publish like this:
php artisan vendor:publish --provider="Sebbmyr\LaravelTeams\TeamsConnectorServiceProvider"
... or you simple add the following to your .env
file:
MICROSOFT_TEAMS_WEBHOOK=<incoming_webhook_url>
How to send simple notification look at the readme of this package sebbmeyer/php-microsoft-teams-connector
You can create your own cards for every purpose you need, just extend the AbstractCard class and implement the getMessage()
function.
\\ Sebbmyr\LaravelTeams\Cards\ForgeCard.php
public function getMessage()
{
return [
"@type" => "MessageCard",
"@context" => "http://schema.org/extensions",
"summary" => "Forge Card",
"themeColor" => ($this->data["status"] === 'success') ? self::STATUS_SUCCESS : self::STATUS_ERROR,
"title" => "Forge deployment message",
"sections" => [
[
"activityTitle" => "",
"activitySubtitle" => "",
"activityImage" => "",
"facts" => [
[
"name" => "Server:",
"value" => $this->data["server"]['name']
],
[
"name" => "Site",
"value" => "[". $this->data["site"]["name"] ."](http://". $this->data["site"]["name"] .")"
], [
"name" => "Commit hash:",
"value" => "[". $this->data["commit_hash"] ."](https://github.com/sebbmeyer/laravel-teams-connector/blob/master/". $this->data["commit_url"] .")"
],
[
"name" => "Commit message",
"value" => $this->data["commit_message"]
]
],
"text" => ($this->data["status"] === 'success') ? $this->data["commit_author"] ." deployed some fresh code!" : "Something went wrong :/"
]
]
];
}
You can use the CustomCard
class and dynamically build out our card. Based on Microsoft Legacy Card
$card = New Sebbmyr\LaravelTeams\Cards\CustomCard('Title Test','Text Test');
$card->addColor('800080')
->addFactsText('Supported Laravel Versions',['5.x','6.x'])
->addFactsText('Unsupported Laravel Versions',['Before Version 5'])
->addAction('Laravel Website','http://www.laravel.com')
->addFacts('Facts Section',['Fact Name 1' => 'Fact Value 1','Fact Name 2' => 'Fact Value 2']);
app('TeamsConnector')->send($card);
This Microsoft Teams connector for Laravel is open-sourced software licensed under the MIT license