PHP code example of arhx / telegram-log-channel

1. Go to this page and download the library: Download arhx/telegram-log-channel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

arhx / telegram-log-channel example snippets


    'channels' => [
        // ... other channels

        'telegram' => [
            'driver' => 'telegram',
            'token' => env('TELEGRAM_LOG_BOT_TOKEN'),
            'chat_id' => env('TELEGRAM_LOG_CHAT_ID'),
            'topic_id' => env('TELEGRAM_LOG_TOPIC_ID'), // optional, forum supergroups
            'level' => env('TELEGRAM_LOG_LEVEL', 'debug'), // Example of overriding the level
        ],
    ],
    

'channels' => [
    'telegram' => [ // errors → "ERROR" topic
        'driver' => 'telegram',
        'token' => env('TELEGRAM_LOG_BOT_TOKEN'),
        'chat_id' => env('TELEGRAM_LOG_CHAT_ID'),
        'topic_id' => env('TELEGRAM_LOG_TOPIC_ID'),
        'level' => 'warning',
    ],

    'telegram_registration' => [ // registration events → "REGISTRATION" topic
        'driver' => 'telegram',
        'token' => env('TELEGRAM_LOG_BOT_TOKEN'),
        'chat_id' => env('TELEGRAM_LOG_CHAT_ID'),
        'topic_id' => env('TELEGRAM_LOG_REGISTRATION_TOPIC_ID'),
        'level' => 'info',
        'throttle' => 0,
    ],
],

'stack' => [
    'driver' => 'stack',
    'channels' => ['daily', 'telegram'], // Add 'telegram' here
    'ignore_exceptions' => false,
],
bash
php artisan vendor:publish --tag=telegram-log-channel-config
bash
php artisan telegram-log:test
bash
php artisan telegram-log:test