Download the PHP package technobase/alert without Composer
On this page you can find all versions of the php package technobase/alert. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download technobase/alert
More information about technobase/alert
Files in technobase/alert
Package alert
Short Description Laravel package for sending error notifications to Telegram channels with detailed context and stack traces
License MIT
Homepage https://github.com/technobase/alert
Informations about the package alert
Alert - Laravel Telegram Error Notifications
A Laravel package for sending comprehensive error notifications to Telegram channels with detailed context, stack traces, and environment information.
Features
- ๐จ Automatic Error Notifications - Captures all exceptions and sends them to Telegram
- ๐ Rich Error Context - Includes file, line, URL, user ID, environment, and stack trace
- โ๏ธ Configurable - Control which environments send notifications
- ๐ Safe - Won't break your app if Telegram is unreachable
- ๐ฏ Queue Support - Async notification processing to avoid blocking requests
- ๐งช Testable - Includes test notification for verifying setup
- ๐จ Markdown Formatting - Clean, readable error messages in Telegram
Requirements
- PHP 8.2 or higher
- Laravel 11.x or 12.x
- A Telegram Bot Token (get one from @BotFather)
- A Telegram Channel/Group/Chat ID
Installation
Install the package via Composer:
The service provider will be automatically registered via Laravel's package discovery.
Configuration
1. Publish Configuration File
This creates config/alert.php in your application.
2. Set Environment Variables
Add these to your .env file:
3. Configure Telegram Bot
- Create a bot by messaging @BotFather on Telegram
- Send
/newbotand follow the prompts - Copy the bot token to your
.envfile - Create a Telegram channel for errors
- Add your bot as an administrator to the channel
- Get the channel ID (use @userinfobot or check Telegram API)
- Add the chat ID to your
.envfile
Usage
Automatic Error Notifications
Once configured, Alert automatically catches all exceptions in production and staging environments and sends them to your Telegram channel.
No additional code needed! Just let your application run.
Testing the Integration
Send a test notification to verify your setup:
Or create a test route:
Manual Error Notifications
You can manually send error notifications:
Disabling for Specific Environments
Edit config/alert.php:
Or disable entirely:
Configuration Options
| Option | Environment Variable | Default | Description |
|---|---|---|---|
enabled |
ALERT_ENABLED |
true |
Enable/disable package |
bot_token |
TELEGRAM_BOT_TOKEN |
null |
Telegram bot API token |
chat_id |
TELEGRAM_CHAT_ID |
null |
Telegram chat/channel ID |
enabled_environments |
- | ['production', 'staging'] |
Environments to send notifications |
notification_title |
ALERT_NOTIFICATION_TITLE |
๐จ Application Error |
Title of error notifications |
trace_lines |
ALERT_TRACE_LINES |
10 |
Max stack trace lines |
queue |
ALERT_QUEUE |
true |
Queue notifications |
queue_connection |
ALERT_QUEUE_CONNECTION |
null |
Queue connection to use |
log_notification_errors |
ALERT_LOG_ERRORS |
false |
Log notification failures |
include_request_data |
ALERT_INCLUDE_REQUEST |
true |
Include URL & user ID |
include_environment |
ALERT_INCLUDE_ENV |
true |
Include environment name |
Example Telegram Notification
0 UserController.php(23): UserService->process()
1 Router.php(822): UserController->store()
2 Pipeline.php(180): Router->dispatch()
...
Troubleshooting
Bot Not Receiving Messages
- Check bot is admin: Your bot must be added as an administrator to the channel
- Verify chat ID: Use negative ID for channels (e.g.,
-1001234567890) - Test with curl:
No Notifications in Production
- Check environment: Verify
APP_ENV=productionorstaging - Check config: Run
php artisan config:cacheafter changes - Check logs: Enable
ALERT_LOG_ERRORS=trueand checkstorage/logs/laravel.log - Check queue: If using queues, ensure queue worker is running:
php artisan queue:work
DNS Resolution Errors
If you see Could not resolve host: api.telegram.org:
- Check internet connectivity
- Flush DNS cache:
sudo dscacheutil -flushcache(macOS) - Try different DNS servers (e.g., Google DNS 8.8.8.8)
- Check firewall/antivirus settings
Notifications Delayed
If notifications arrive late:
- Check queue worker:
php artisan queue:workmust be running - Disable queue: Set
ALERT_QUEUE=falsefor immediate sending - Check queue connection: Verify your
QUEUE_CONNECTIONis working
Security
Sensitive Data
Be careful not to send sensitive information in error notifications:
- Avoid logging passwords, API keys, or tokens
- Consider filtering context data before sending
- Use environment-specific chat channels
- Review stack traces for sensitive information
Best Practices
- Use separate Telegram channels for different environments
- Restrict channel access to authorized personnel only
- Regularly rotate bot tokens
- Monitor notification volume to detect attacks
Testing
Run the package tests:
Or with PHPUnit directly:
Changelog
Please see CHANGELOG for recent changes.
Contributing
Contributions are welcome! Please submit pull requests to the main repository.
License
The MIT License (MIT). Please see License File for more information.
Credits
- Technobase - Package development and maintenance
- Laravel Notification Channels - Telegram integration
- All contributors
Support
For support, please contact [email protected] or open an issue on GitHub.
Made with โค๏ธ by Technobase
All versions of alert with dependencies
illuminate/notifications Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0
laravel-notification-channels/telegram Version ^5.0|^6.0