Download the PHP package codebuds/mattermost-publication-bundle without Composer
On this page you can find all versions of the php package codebuds/mattermost-publication-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codebuds/mattermost-publication-bundle
More information about codebuds/mattermost-publication-bundle
Files in codebuds/mattermost-publication-bundle
Package mattermost-publication-bundle
Short Description Bundle to publish to mattermost webhooks
License MIT
Informations about the package mattermost-publication-bundle
Mattermost Publication Bundle
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 :
and adding the webhook URL to your environment variables :
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
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):
In an eventSubscriber you can inject the publisher in the constructor :
and then, inside any function, you can publish a message thanks to the bundle :
You can also use twig to create message templates, if you create the following template file in templates/mattermost/message.md.twig :
You can render it and use it like the following :
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.
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 @
: