vbushuev / laravel-mattermost
Laravel logging package for Mattermost webhooks
Package info
github.com/vbushuev/laravel-mattermost
Type:laravel-package
pkg:composer/vbushuev/laravel-mattermost
1.1.0
2026-11-12 06:30 UTC
Requires
- php: ^8.2
- laravel/framework: ^11.0|^12.0|^13.0
- monolog/monolog: ^2.0|^3.0
Requires (Dev)
- mockery/mockery: ^1.4
- orchestra/testbench: ^9.0|^10.0|^11.0
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This package provides a way to send notifications to Mattermost via webhooks.
Installation
Add package directory
/packages/vbushuev/laravel-mattermost
Add config to composer.json to autoload section
"autoload": { "psr-4": { ... "Bushuev\\Mattermost\\": "packages/vbushuev/laravel-mattermost/src" } }
Publish the config file:
php artisan vendor:publish --provider="Bushuev\Mattermost\Providers\ServiceProvider"
Configure your Mattermost webhook URL and token in .env:
MATTERMOST_URL=https://chat.service.it-pvk.ru/hooks/ywaj4kqfit8edkggiuayr5iyro MATTERMOST_TOKEN=ywaj4kqfit8edkggiuayr5iyro
Usage
Send Notification via Mattermost Channel
Add the channel to your notifiable model:
// In a User model or other notifiable class public function routeNotificationForMattermost($notification) { // Return the webhook URL or null to use default config return env('MATTERMOST_URL'); }
Send a Notification
You can now send notifications through Mattermost:
// Using the notification channel directly use Bushuev\Mattermost\Notifications\MattermostNotification; // In your controller, command, etc. $notifiable->notify(new MattermostNotification('Hello from Laravel!')); // Or send it directly using the service container app('mattermost')->handle($formatter);
Creating Custom Notifications
Create a custom notification class:
use Illuminate\Notifications\Notification; use Bushuev\Mattermost\Formatters\DefaultFormatter; class MyCustomNotification extends Notification { public function via($notifiable) { return ['mattermost']; } public function toMattermost() { return new DefaultFormatter( enviroment: config('app.env'), service: config('app.name'), message: 'Custom message', request: !app()->runningInConsole() ? request() : null, isConsole: app()->runningInConsole(), trace: null ); } }
Features
- Integration with Laravel's notification system
- Support for different formatters
- Simple webhook configuration
- Console and HTTP request context handling