composer require 'arus/monolog-telegram-handler:^2.1'
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');
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