arus / monolog-telegram-handler
Arus // Monolog Telegram Handler for PHP 7.2+ (incl. PHP 8)
Installs: 2 835
Dependents: 1
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: ^7.2|^8.0
- monolog/monolog: ^2.0
Requires (Dev)
- arus/php-coding-standard: ^1.0
- phpunit/phpunit: 7.5.20|9.5.0
This package is auto-updated.
Last update: 2024-11-29 05:57:06 UTC
README
Installation (via composer)
composer require 'arus/monolog-telegram-handler:^2.1'
How to use?
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!');
Send a photo
$logger->debug('Hello, world!', [ 'photo' => 'https://example.com/photo.jpeg', ]);
Send an animation
$logger->debug('Hello, world!', [ 'animation' => 'https://example.com/animation.gif', ]);
Send a video
$logger->debug('Hello, world!', [ 'video' => 'https://example.com/video.mp4', ]);
Set custom API URL (relevant for Russia)
Via API
$sender->setUrl('https://proxy.api.telegram.example.com');
Via environment
putenv('TELEGRAM_URL=https://proxy.api.telegram.example.com');
Test run
Create your phpunit.xml
file:
cp phpunit.xml.dist phpunit.xml
Open your phpunit.xml
file and set the following environment variables: TELEGRAM_TOKEN
and TELEGRAM_RECIPIENT
, then:
php vendor/bin/phpunit --colors=always --coverage-text