PHP code example of arus / monolog-telegram-handler

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

    

arus / monolog-telegram-handler example snippets


use Arus\Monolog\Handler\TelegramHandler;
use Monolog\Logger;

$token = '000000000:000000000ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$recipient = '000000000';

$sender = new TelegramHandler($token, $recipient);

$logger = new Logger('app');
$logger->pushHandler($sender);

$logger->debug('Hello, world!');

$logger->debug('Hello, world!', [
    'photo' => 'https://example.com/photo.jpeg',
]);

$logger->debug('Hello, world!', [
    'animation' => 'https://example.com/animation.gif',
]);

$logger->debug('Hello, world!', [
    'video' => 'https://example.com/video.mp4',
]);

$sender->setUrl('https://proxy.api.telegram.example.com');

putenv('TELEGRAM_URL=https://proxy.api.telegram.example.com');
bash
php vendor/bin/phpunit --colors=always --coverage-text