sajadjanat/laravel-mattermost-bot-logger
Composer 安装命令:
composer require sajadjanat/laravel-mattermost-bot-logger
包简介
A custom Laravel logging channel to send logs and exceptions to Mattermost using Bot Token (API v4)
README 文档
README
A custom logging channel for Laravel and Lumen that sends logs and exceptions directly to Mattermost using a Bot Token via the Mattermost API v4.
This package provides structured, readable log messages with severity indicators and full exception stack traces, making it suitable for production monitoring and error reporting.
Keywords: laravel logging, lumen logging, mattermost logger, mattermost bot, monolog handler, error monitoring
Features
- Compatible with Laravel 9, 10, 11+ and Lumen 8, 9, 10+
- Full support for Monolog 3.x
- Sends all log levels with severity-based formatting
- Detailed exception reporting including full stack trace
- Secure authentication via Mattermost Bot Token
- No external dependencies beyond the framework and Guzzle
- Simple
.env-based configuration - Works with both Laravel and Lumen without code duplication
Requirements
- PHP 8.1 or higher
- Laravel 9+ or Lumen 8+
- Mattermost Bot Account with Access Token
Installation
composer require sajadjanat/laravel-mattermost-bot-logger
The package uses Composer autoloading and works out-of-the-box with both Laravel and Lumen.
Configuration
1. Publish configuration (Laravel only – optional)
php artisan vendor:publish --tag=mattermost-logging-config
This will create:
config/logging-mattermost.php
Lumen note: Lumen does not support vendor:publish. You can manually copy the configuration array into your logging setup.
2. Environment variables
Add the following to your .env file:
MATTERMOST_BASE_URL=https://your-mattermost-instance.com MATTERMOST_BOT_TOKEN=your_bot_token_here MATTERMOST_CHANNEL_ID=your_channel_id MATTERMOST_BOT_USERNAME=Laravel/Lumen Errors MATTERMOST_LOG_LEVEL=error
How to obtain values:
- Base URL: Your Mattermost server URL (without trailing slash)
- Bot Token: System Console → Integrations → Bot Accounts → Add Bot
- Channel ID: Channel menu → View Info → Copy Channel ID
3. Laravel logging channel setup
In config/logging.php:
'channels' => [ 'mattermost' => config('logging-mattermost.mattermost'), 'stack' => [ 'driver' => 'stack', 'channels' => ['single', 'daily', 'mattermost'], 'ignore_exceptions' => false, ], ];
Set default channel in .env:
LOG_CHANNEL=stack
4. Lumen setup (bootstrap/app.php)
$app->configure('logging'); $app->configureMonologUsing(function (Monolog\Logger $monolog) { $monolog->pushHandler( new \Sajadjanat\MattermostBotLogger\MattermostBotHandler( level: \Monolog\Logger::toMonologLevel( env('MATTERMOST_LOG_LEVEL', 'error') ) ) ); return $monolog; });
You may also use the handler manually via Log::channel('mattermost').
Manual Configuration Array
If you prefer not to publish a config file, use the following channel definition:
'mattermost' => [ 'driver' => 'monolog', 'handler' => \Sajadjanat\MattermostBotLogger\MattermostBotHandler::class, 'level' => env('MATTERMOST_LOG_LEVEL', 'error'), 'base_url' => env('MATTERMOST_BASE_URL'), 'token' => env('MATTERMOST_BOT_TOKEN'), 'channel_id' => env('MATTERMOST_CHANNEL_ID'), 'bot_username' => env('MATTERMOST_BOT_USERNAME', 'Laravel/Lumen Bot'), ],
License
MIT License
Contributing
Pull requests are welcome. For major changes, please open an issue first.
Made for the Laravel & Lumen ecosystem.
sajadjanat/laravel-mattermost-bot-logger 适用场景与选型建议
sajadjanat/laravel-mattermost-bot-logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「logging」 「exceptions」 「bot」 「laravel」 「Mattermost」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sajadjanat/laravel-mattermost-bot-logger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sajadjanat/laravel-mattermost-bot-logger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sajadjanat/laravel-mattermost-bot-logger 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
php7ify is a project that brings new php7 classes and exceptions to php 5.x.
Dialogflow php sdk
The CodenamePHP Platform core that contains basic interfaces, exceptions etc..
A Zend Framework module that sets up Monolog for logging in applications.
Laravel 5.6 Monolog custom telegram channel
A simple package to better handle Exceptions.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-17