PHPackages                             codebuds/mattermost-publication-bundle - 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. codebuds/mattermost-publication-bundle

ActiveSymfony-bundle

codebuds/mattermost-publication-bundle
======================================

Bundle to publish to mattermost webhooks

0.6.0(2y ago)5737MITPHPPHP ^8.3

Since Apr 5Pushed 2y ago2 watchersCompare

[ Source](https://github.com/codebuds33/mattermost-publication-bundle)[ Packagist](https://packagist.org/packages/codebuds/mattermost-publication-bundle)[ RSS](/packages/codebuds-mattermost-publication-bundle/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (2)Versions (13)Used By (0)

Mattermost Publication Bundle
=============================

[](#mattermost-publication-bundle)

Configuration
-------------

[](#configuration)

This bundle allows you to easily publish text to a Mattermost webhook.

In order to do so you need to add configuration to your symfony by, for example, adding a `mattermost_publication.yaml` file to the config/packages containing :

```
mattermost_publication:
  webhook_url: '%env(MATTERMOST_WEBHOOK_URL)%'
  username: 'My general username'
  channel: 'general-channel'
  icon_url: 'https://mysite.com/build/static/my_logo.webp'
```

and adding the webhook URL to your environment variables :

```
###> codebuds/mattermost-publication###
MATTERMOST_WEBHOOK_URL="http://{your-mattermost-site}/hooks/xxx-generatedkey-xxx"
###< codebuds/mattermost-publication###

```

This will set the general configuration for all publications. If these are not set you have to make sure to at least add a webhook URL to the message element you want to publish.

Usage
-----

[](#usage)

### Basic text publication

[](#basic-text-publication)

You can use the publisher directly inside a controller function by adding it as a parameter (if you have a general webhook\_url configured):

```
/**
 * @Route("/submit-donation")
 * @param MattermostPublication $publication
 * @return JsonResponse
 */
public function submitDonationForm(MattermostPublication $publication)
{
    try {
        $publication->publish(
            "# donation made"
        );
    } catch (\Exception $e) {
        return new JsonResponse(['message' => $e->getMessage()], 500);
    }
}
```

In an eventSubscriber you can inject the publisher in the constructor :

```
public function __construct(MattermostPublication $publication)
{
    $this->publication = $publication;
}
```

and then, inside any function, you can publish a message thanks to the bundle :

```
try {
    $this->publication->publish(
        "# New contact form submission : " .
        "\n " .
        "**Name : **" . $message->getName() .
        "\n " .
        "**Email : **" . $message->getEmail() .
        "\n" .
        "### Message" .
        "\n" .
        $message->getMessage()
    );
} catch (\Exception $e) {
    return new JsonResponse(['message' => $e->getMessage()], 500);
}
```

You can also use twig to create message templates, if you create the following template file in templates/mattermost/message.md.twig :

```
# New contact form submission

**Name : ** {{ message.name }}

**Email : ** {{ message.email }}

### Message

{{ message.message }}
```

You can render it and use it like the following :

```
$messageText = $this->twig->render('mattermost/message.md.twig', ['message' => $message]);
$this->publication->publish($messageText);
```

### Configured publication

[](#configured-publication)

As it was possible to publish simple text it is also possible to configure the message to all available Mattermost incoming webhook features.

In order to do so instead of just publishing text a `CodeBuds\MattermostPublicationBundle\Model\Message` must be created.

```
use CodeBuds\MattermostPublicationBundle\Model\Message as MMMessage;
use CodeBuds\MattermostPublicationBundle\MattermostPublication;
use Twig\Environment;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class MyController extends AbstractController
{
    public function submitDonationForm(MattermostPublication $publication, Environment $twig)
    {
        $variable = "I am a variable";
        try {
            $mmMessage = (new MMMessage())
                ->setText($twig->render('mattermost/mymessage.md.twig', ['myVariable' => $variable]))
                ->setUsername('MyUsername')
                ->setChannel('MyChannel')
                ->setIconUrl('https://mysite.com/build/static/my_logo.webp')
                ->setWebhookUrl('http://otherwebhookurl');

            $publication->publish($mmMessage);
        } catch (\Exception $e) {
            return $e->getMessage();
        }
    }
}
```

Doing it this way will override the general settings from the configuration file. If something has been set in the configuration file and the setter is not used the general value will be in the message.

If you want to send a direct message and the incoming webhook is not locked to a channel in mattermost you can set the channel to the username preceded by `@` :

```
$publication->publish((new Message())
    ->setText("Hello John !")
    ->setChannel("@john"));
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~129 days

Recently: every ~341 days

Total

12

Last Release

812d ago

PHP version history (4 changes)0.1.0PHP ^7.4

0.3.4PHP ^7.4 || ^8.0

0.4.0PHP ^8.0

0.6.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/0480f4640e4b77d81842082e7b73e903428b52b68f58e244cdc0108a72939004?d=identicon)[DennisdeBest](/maintainers/DennisdeBest)

![](https://www.gravatar.com/avatar/10d081369f263e74ed4a415f05d3304640e8c777e211f2776340ff0a879f733c?d=identicon)[CodeBuds](/maintainers/CodeBuds)

---

Top Contributors

[![DennisdeBest](https://avatars.githubusercontent.com/u/15683927?v=4)](https://github.com/DennisdeBest "DennisdeBest (29 commits)")

### Embed Badge

![Health badge](/badges/codebuds-mattermost-publication-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/codebuds-mattermost-publication-bundle/health.svg)](https://phpackages.com/packages/codebuds-mattermost-publication-bundle)
```

###  Alternatives

[temporal/sdk

Temporal SDK

4002.2M18](/packages/temporal-sdk)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

50570.7k1](/packages/web-auth-webauthn-framework)[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)[acquia/orca

A tool for testing a company's software packages together in the context of a realistic, functioning, best practices Drupal build

32902.4k](/packages/acquia-orca)[mahocommerce/maho

Free and open source ecommerce platform, created in 2024 on the M1 platform, PHP 8.3+

1322.1k12](/packages/mahocommerce-maho)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
