PHP code example of swarletta / telegram-logger

1. Go to this page and download the library: Download swarletta/telegram-logger 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/ */

    

swarletta / telegram-logger example snippets

 php


elegramHandler;
use Monolog\Formatter\LineFormatter;
use Monolog\Logger;

$token = '000000000:XXXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$chat_id = 999999999;
$log = new Logger('telegram-channel');

$handler = new TelegramHandler($token, $chat_id, Logger::DEBUG);
$handler->setFormatter(new LineFormatter("%message%", null, true));
$log->pushHandler($handler);

$log->debug('Test message');