PHPackages                             actived/microsoft-teams-notifier - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. actived/microsoft-teams-notifier

AbandonedArchivedLibrary[Logging &amp; Monitoring](/categories/logging)

actived/microsoft-teams-notifier
================================

Monolog handler sending Microsoft Teams notifications with an Incoming Webhook

V1.3.0(3y ago)14381.9k↓38.2%5[1 issues](https://github.com/actived/microsoft-teams-notifier/issues)2MITPHPPHP ^8.1

Since Oct 5Pushed 3y ago1 watchersCompare

[ Source](https://github.com/actived/microsoft-teams-notifier)[ Packagist](https://packagist.org/packages/actived/microsoft-teams-notifier)[ Docs](https://github.com/actived/microsoft-teams-notifier)[ RSS](/packages/actived-microsoft-teams-notifier/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (3)Versions (4)Used By (2)

Actived Microsoft Teams Notifier
================================

[](#actived-microsoft-teams-notifier)

[![Package Version](https://camo.githubusercontent.com/69044af3c98c57461e5b5b9704929da6fd116b5f0b3dbbdf13548b84cc85ba7d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f56657273696f6e2d312e322e302d627269676874677265656e2e737667)](https://camo.githubusercontent.com/69044af3c98c57461e5b5b9704929da6fd116b5f0b3dbbdf13548b84cc85ba7d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f56657273696f6e2d312e322e302d627269676874677265656e2e737667)

A PHP package that defines custom Monolog handler to send Microsoft Teams notifications with an Incoming Webhook. The package aims to provide global messaging &amp; log system that uses Microsoft Teams "MessageCard" notification and uses Monolog logging library.

Features
========

[](#features)

- Monolog wiring with Microsoft Teams channel
- Application error notifying
- Simple messaging

Install
=======

[](#install)

```
$ composer require actived/microsoft-teams-notifier
```

### Since version 1.1 of the package, `"symfony/monolog-bundle"` was removed and replaced with `"monolog/monolog"` dependency that makes Actived Microsoft Teams Notifier more flexible for global use:

[](#since-version-11-of-the-package-symfonymonolog-bundle-was-removed-and-replaced-with-monologmonolog-dependency-that-makes-actived-microsoft-teams-notifier-more-flexible-for-global-use)

Please consider running `composer suggest` command to install required and missing dependencies related to framework you use (ex. Symfony):

```
$ composer suggest
actived/microsoft-teams-notifier suggests:
 - symfony/monolog-bundle: The MonologBundle provides integration of the Monolog library into the Symfony framework.
```

Microsoft Teams Webhook setting
===============================

[](#microsoft-teams-webhook-setting)

Follow these steps to set up new Webhook:

- In Microsoft Teams, choose More options (⋯) next to the channel name and then choose 'Connectors'
- Find in the list of Connectors the 'Incoming Webhook' option, and choose 'Add'
- Provide required information for the new Webhook
- Copy the Webhook url - that information will be used to configure the package with `ACTIVED_MS_TEAMS_DSN`

Symfony configuration
=====================

[](#symfony-configuration)

Place the code below in `.env` file:

```
###> actived/microsoft-teams-notifier ###
ACTIVED_MS_TEAMS_DSN=webhook_dsn
###< actived/microsoft-teams-notifier ###
```

Register `ActivedMicrosoftTeamsHandler.php` as a new service with the code below:

```
// config\services.yaml

services:
    ...

    # ACTIVED MICROSOFT TEAMS NOTIFIER
+    actived_ms_teams_handler:
+        class: Actived\MicrosoftTeamsNotifier\Handler\MicrosoftTeamsHandler
+        arguments:
+            $webhookDsn: '%env(ACTIVED_MS_TEAMS_DSN)%'
+            $level: 'error'
+            $title: 'Message title'
+            $subject: 'Message subject'
+            $emoji:  '&#x1F6A8'
+            $color: '#fd0404'
+            $format: '[%%datetime%%] %%channel%%.%%level_name%%: %%message%%'
```

> *$webhookDsn:*
> Microsoft Teams webhook url
>
> *$level:*
> the minimum level for handler to be triggered and the message be logged in the channel (Monolog/Logger class: ‘error’ = 400)
>
> *$title (nullable):*
> title of Microsoft Teams Message
>
> *$subject (nullable):*
> subject of Microsoft Teams Message
>
> *$emoji (nullable):*
> emoji of Microsoft Teams Message (displayed next to the message title). Value needs to reflect the pattern: ‘&amp;#x&lt;EMOJI\_HEX\_CODE&gt;’
>
> *$color (nullable):*
> hexadecimal color value for Message Card color theme
>
> *$format (nullable):*
> every handler uses a Formatter to format the record before logging it. This attribute can be set to overwrite default log message (available options: %datetime% | %extra.token% | %channel% | %level\_name% | %message%).

Modify your Monolog settings that will point from now to the new handler:

```
// config\packages\dev\monolog.yaml
// config\packages\prod\monolog.yaml

monolog:
    handlers:
        ...

        # ACTIVED MICROSOFT TEAMS NOTIFIER
+        teams:
+            type: service
+            id: actived_ms_teams_handler
```

> *type:*
> handler type (in our case this references custom notifier service)
>
> *id:*
> notifier service class \\Actived\\MicrosoftTeamsNotifier\\LogMonolog

Laravel configuration
=====================

[](#laravel-configuration)

Place the code below in `.env` file:

```
###> actived/microsoft-teams-notifier ###
ACTIVED_MS_TEAMS_DSN=webhook_dsn
###< actived/microsoft-teams-notifier ###
```

Modify your Monolog logging settings that will point to the new handler:

### Att: definition of ALL parameters is compulsory - please use NULL value for attributes you want to skip.

[](#att-definition-of-all-parameters-is-compulsory---please-use-null-value-for-attributes-you-want-to-skip)

```
// config\logging.php
