PHPackages                             technobase/alert - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. technobase/alert

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

technobase/alert
================

Laravel package for sending error notifications to Telegram channels with detailed context and stack traces

1.0.1(5mo ago)19[1 PRs](https://github.com/TechnoBase-krd/alert/pulls)MITPHPPHP ^8.2CI passing

Since Nov 28Pushed 1mo agoCompare

[ Source](https://github.com/TechnoBase-krd/alert)[ Packagist](https://packagist.org/packages/technobase/alert)[ Docs](https://github.com/technobase/alert)[ RSS](/packages/technobase-alert/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (9)Versions (4)Used By (0)

Alert - Laravel Telegram Error Notifications
============================================

[](#alert---laravel-telegram-error-notifications)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2dc50cbc9b3ca52f41372be08b159d1ec0b3e6dd4fde577b3a552b3bc94efbaa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746563686e6f626173652f616c6572742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/technobase/alert)[![Total Downloads](https://camo.githubusercontent.com/1181eb77e1c3d82d12ab05fba3f15b0b5167ede7aba0f7a2134058c4a1c43c6b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746563686e6f626173652f616c6572742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/technobase/alert)[![License](https://camo.githubusercontent.com/6c5b110b21e222eb6ad7dbf04f0099d8e11390d0bf1e4f164ea6093966cb17d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746563686e6f626173652f616c6572742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/technobase/alert)

A Laravel package for sending comprehensive error notifications to Telegram channels with detailed context, stack traces, and environment information.

Features
--------

[](#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
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 11.x or 12.x
- A Telegram Bot Token (get one from [@BotFather](https://t.me/BotFather))
- A Telegram Channel/Group/Chat ID

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require technobase/alert
```

The service provider will be automatically registered via Laravel's package discovery.

Configuration
-------------

[](#configuration)

### 1. Publish Configuration File

[](#1-publish-configuration-file)

```
php artisan vendor:publish --tag=alert-config
```

This creates `config/alert.php` in your application.

### 2. Set Environment Variables

[](#2-set-environment-variables)

Add these to your `.env` file:

```
# Telegram Bot Token (from @BotFather)
TELEGRAM_BOT_TOKEN=your-bot-token-here

# Telegram Chat ID (channel, group, or private chat)
TELEGRAM_CHAT_ID=your-chat-id-here

# Optional: Customize settings
ALERT_ENABLED=true
ALERT_NOTIFICATION_TITLE="🚨 Application Error"
ALERT_TRACE_LINES=10
ALERT_QUEUE=true
```

### 3. Configure Telegram Bot

[](#3-configure-telegram-bot)

1. Create a bot by messaging [@BotFather](https://t.me/BotFather) on Telegram
2. Send `/newbot` and follow the prompts
3. Copy the bot token to your `.env` file
4. Create a Telegram channel for errors
5. Add your bot as an administrator to the channel
6. Get the channel ID (use [@userinfobot](https://t.me/userinfobot) or check Telegram API)
7. Add the chat ID to your `.env` file

Usage
-----

[](#usage)

### Automatic Error Notifications

[](#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

[](#testing-the-integration)

Send a test notification to verify your setup:

```
use Illuminate\Support\Facades\Notification;
use Technobase\Alert\Notifications\TestTelegramNotification;

Notification::route('telegram', config('alert.chat_id'))
    ->notify(new TestTelegramNotification('Testing Alert integration'));
```

Or create a test route:

```
Route::get('/test-alert', function() {
    \Notification::route('telegram', config('alert.chat_id'))
        ->notify(new \Technobase\Alert\Notifications\TestTelegramNotification());

    return 'Test notification sent!';
});
```

### Manual Error Notifications

[](#manual-error-notifications)

You can manually send error notifications:

```
use Illuminate\Support\Facades\Notification;
use Technobase\Alert\Notifications\TelegramErrorNotification;

try {
    // Your code that might fail
    riskyOperation();
} catch (\Exception $e) {
    Notification::route('telegram', config('alert.chat_id'))
        ->notify(new TelegramErrorNotification(
            title: 'Custom Error Title',
            message: $e->getMessage(),
            context: [
                'file' => $e->getFile(),
                'line' => $e->getLine(),
                'custom_data' => 'additional context',
            ]
        ));

    throw $e; // Re-throw if needed
}
```

### Disabling for Specific Environments

[](#disabling-for-specific-environments)

Edit `config/alert.php`:

```
'enabled_environments' => [
    'production',
    'staging',
    // 'local' - not included, won't send notifications locally
],
```

Or disable entirely:

```
ALERT_ENABLED=false
```

Configuration Options
---------------------

[](#configuration-options)

OptionEnvironment VariableDefaultDescription`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 &amp; user ID`include_environment``ALERT_INCLUDE_ENV``true`Include environment nameExample Telegram Notification
-----------------------------

[](#example-telegram-notification)

```
🚨 **Application Error**

**Message**: Call to undefined method User::nonExistent()

**File**: `/var/www/app/Services/UserService.php:42`
**URL**: `https://api.example.com/users/5`
**User**: `ID: 123`
**Environment**: `production`

**Trace**:
```

\#0 UserController.php(23): UserService-&gt;process() #1 Router.php(822): UserController-&gt;store() #2 Pipeline.php(180): Router-&gt;dispatch() ...

```

```

Troubleshooting
---------------

[](#troubleshooting)

### Bot Not Receiving Messages

[](#bot-not-receiving-messages)

1. **Check bot is admin**: Your bot must be added as an administrator to the channel
2. **Verify chat ID**: Use negative ID for channels (e.g., `-1001234567890`)
3. **Test with curl**: ```
    curl -X POST "https://api.telegram.org/bot{YOUR_TOKEN}/sendMessage" \
      -d "chat_id={YOUR_CHAT_ID}" \
      -d "text=Test message"
    ```

### No Notifications in Production

[](#no-notifications-in-production)

1. **Check environment**: Verify `APP_ENV=production` or `staging`
2. **Check config**: Run `php artisan config:cache` after changes
3. **Check logs**: Enable `ALERT_LOG_ERRORS=true` and check `storage/logs/laravel.log`
4. **Check queue**: If using queues, ensure queue worker is running: `php artisan queue:work`

### DNS Resolution Errors

[](#dns-resolution-errors)

If you see `Could not resolve host: api.telegram.org`:

1. Check internet connectivity
2. Flush DNS cache: `sudo dscacheutil -flushcache` (macOS)
3. Try different DNS servers (e.g., Google DNS 8.8.8.8)
4. Check firewall/antivirus settings

### Notifications Delayed

[](#notifications-delayed)

If notifications arrive late:

1. **Check queue worker**: `php artisan queue:work` must be running
2. **Disable queue**: Set `ALERT_QUEUE=false` for immediate sending
3. **Check queue connection**: Verify your `QUEUE_CONNECTION` is working

Security
--------

[](#security)

### Sensitive Data

[](#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

[](#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
-------

[](#testing)

Run the package tests:

```
composer test
```

Or with PHPUnit directly:

```
vendor/bin/phpunit
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for recent changes.

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit pull requests to the main repository.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

Credits
-------

[](#credits)

- **Technobase** - Package development and maintenance
- [Laravel Notification Channels](https://github.com/laravel-notification-channels/telegram) - Telegram integration
- All contributors

Support
-------

[](#support)

For support, please contact  or open an issue on GitHub.

---

Made with ❤️ by [Technobase](https://technobase.krd)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance81

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

172d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f82005f7a1ad5640720f6d9b75bc27563f67f46a06dcc23edad38e10c1fb38b3?d=identicon)[codezardasht](/maintainers/codezardasht)

---

Top Contributors

[![mhamadYaseen](https://avatars.githubusercontent.com/u/158322177?v=4)](https://github.com/mhamadYaseen "mhamadYaseen (15 commits)")[![codezardasht](https://avatars.githubusercontent.com/u/35077108?v=4)](https://github.com/codezardasht "codezardasht (8 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelmonitoringtelegramalerterror-trackingerror-notificationtechnobase

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/technobase-alert/health.svg)

```
[![Health](https://phpackages.com/badges/technobase-alert/health.svg)](https://phpackages.com/packages/technobase-alert)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

86910.0M83](/packages/spatie-laravel-health)[rollbar/rollbar-laravel

Rollbar error monitoring integration for Laravel projects

14110.4M7](/packages/rollbar-rollbar-laravel)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[kssadi/log-tracker

A powerful, intuitive, and efficient log viewer for Laravel applications.

264.8k](/packages/kssadi-log-tracker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
