Download the PHP package iperamuna/laravel-telegram-log-buttons without Composer
On this page you can find all versions of the php package iperamuna/laravel-telegram-log-buttons. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iperamuna/laravel-telegram-log-buttons
More information about iperamuna/laravel-telegram-log-buttons
Files in iperamuna/laravel-telegram-log-buttons
Package laravel-telegram-log-buttons
Short Description Laravel logging helper for sending Telegram log messages with inline buttons via Monolog, with optional Redis buffer, batch sender, analytics events, easy callback registration, webhook/chat-id helpers, a callback generator with Laravel Prompts, health check, and Pest tests.
License MIT
Homepage https://github.com/iperamuna/laravel-telegram-log-buttons
Informations about the package laravel-telegram-log-buttons
Laravel Telegram Log Buttons
A Laravel package to send Telegram log messages with inline buttons via Monolog, with:
- Instant / buffered modes (Redis-backed batch sender)
TelegramLogBatchFlushedevent for analytics- Config-driven callback routing (
config/telegram-log-callbacks.php) - Artisan callback generator using Laravel Prompts
- Helper commands for webhooks & chat IDs
- Optional health check route
- Customizable message templates (inspired by grkamil/laravel-telegram-logging)
- Pest tests via Orchestra Testbench
Note: The template/view mechanism for formatting log messages is inspired by grkamil/laravel-telegram-logging. Credit goes to the original author for this excellent feature.
Installation
Quick Setup (Recommended)
Run the interactive setup wizard:
This command will:
- ✅ Ask for your Telegram bot token (or use existing)
- ✅ Verify the bot token with Telegram
- ✅ Guide you through connecting to a Telegram group/chat
- ✅ Auto-detect chat ID from recent updates
- ✅ Set up the callback webhook automatically
- ✅ Configure health check endpoint (optional)
- ✅ Select logging mode (instant/buffered)
- ✅ Update your
.envfile with all necessary values
Manual Setup
Publish config:
This publishes:
config/telegram-log.phpconfig/telegram-log-callbacks.php
Configuration
Configure your Telegram bot token and chat ID in .env:
These are automatically loaded from config/telegram-log.php:
Add the Telegram log channel to config/logging.php:
Usage
Telegram Log Buttons
This package extends Laravel's logging system to send messages with inline buttons to Telegram. You can add buttons using three convenient methods:
Method 1: Using buttons() Macro (Fluent Builder)
The buttons() macro returns a TelegramButtonBuilder instance for fluent button creation:
Available methods:
url($text, $url)- Add a URL buttoncallback($text, $callbackData)- Add a callback buttonnewRow()- Start a new row of buttonswithContext($context)- Add extra context datainfo($message, $context = [])- Send as info levelwarning($message, $context = [])- Send as warning levelerror($message, $context = [])- Send as error levelcritical($message, $context = [])- Send as critical levelsend($message, $context = [], $level = 'info')- Send with custom level
Example with multiple rows:
Method 2: Using addButton() Macro (Quick Single Button)
Add a single URL button quickly:
Method 3: Using addButtons() Macro (Multiple Buttons)
Add multiple buttons at once (each button goes on its own row):
Using with Logger Instances
You can also use these macros with logger instances directly:
Button Types
URL Buttons:
Callback Buttons:
Callback buttons trigger webhook callbacks that can be handled by callback handlers (see Callbacks section below).
Message Templates
This package supports customizable Blade templates for formatting log messages, inspired by grkamil/laravel-telegram-logging.
Default Templates
Two templates are included:
telegram-log::standard(default) - Detailed format with environment, time, context, and extra datatelegram-log::minimal- Simple format with just level and message
Configure Template
Set the default template in .env:
Or in config/telegram-log.php:
Override Template Per Channel
You can override the template for a specific logging channel using handler_with:
Create Custom Templates
- Publish views (optional, to customize):
This publishes templates to resources/views/vendor/telegram-log/.
-
Create your custom template in
resources/views/vendor/telegram-log/custom.blade.php: - Use your custom template:
Available Template Variables
Templates receive the following variables:
$level- Log level name (e.g., "ERROR", "INFO")$message- Formatted log message$context- Context array (excluding buttons)$extra- Extra data array$datetime- Formatted datetime string (Y-m-d H:i:s)$environment- Application environment (fromconfig('app.env'))
Callbacks
Callback Generator
Generate callback handler classes using Laravel Prompts:
nameis optional → if omitted, you'll be prompted:- Callback class base name (e.g.
BanUser)
- Callback class base name (e.g.
--actionis optional → if omitted, Prompts will:- Suggest
snake_case(name)(e.g.ban_user) - Let you edit/confirm it
- Suggest
The command will:
-
Generate
app/Telegram/Callbacks/BanUserCallback.php: -
Update
config/telegram-log-callbacks.php: - Print usage hints:
Because it uses Laravel Prompts:
- If you fully specify arguments & options, it runs non-interactive.
- If you omit them, you get a nice interactive flow.
List Registered Callbacks
View all registered callback handlers:
Outputs a table:
Callback Registry & Facade
You can programmatically register callback handlers using the TelegramCallbacks facade:
Note: Handlers registered via the facade will override config-based handlers for the same action.
Commands
Interactive Setup
Interactive wizard that guides you through:
- Bot token setup and verification
- Chat ID detection (with webhook handling)
- Webhook configuration
- Health check setup
- Mode selection (instant/buffered)
.envfile updates
Callback Management
Webhook Management
Chat ID Discovery
Buffered Log Flushing
Health Check Route
Enable the health check endpoint in config/telegram-log.php:
When enabled is true, the package registers:
It returns JSON like:
If TELEGRAM_LOG_HEALTH_SECRET is set, the route expects:
So you can put this behind a probe or internal monitoring.
Tests
Dev dependencies:
pestphp/pestorchestra/testbench
Run tests:
License
MIT – see LICENSE.
All versions of laravel-telegram-log-buttons with dependencies
illuminate/support Version ^11.0|^12.0
illuminate/redis Version ^11.0|^12.0
guzzlehttp/guzzle Version ^7.8
monolog/monolog Version ^3.0
laravel/prompts Version ^0.3.0