Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/autorusltd/monolog-telegram-handler
Monolog Telegram Handler for PHP 7.2+ (incl. PHP 8)
https://github.com/autorusltd/monolog-telegram-handler
monolog monolog-telegram-handler php7 php8 telegram
Last synced: about 2 months ago
JSON representation
Monolog Telegram Handler for PHP 7.2+ (incl. PHP 8)
- Host: GitHub
- URL: https://github.com/autorusltd/monolog-telegram-handler
- Owner: autorusltd
- License: mit
- Created: 2019-06-24T06:37:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-02T14:25:39.000Z (almost 4 years ago)
- Last Synced: 2024-05-07T12:04:51.993Z (9 months ago)
- Topics: monolog, monolog-telegram-handler, php7, php8, telegram
- Language: PHP
- Homepage:
- Size: 22.5 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Monolog Telegram Handler for PHP 7.2+ (incl. PHP 8)
[![Build Status](https://circleci.com/gh/autorusltd/monolog-telegram-handler.svg?style=shield)](https://circleci.com/gh/autorusltd/monolog-telegram-handler)
[![Code Coverage](https://scrutinizer-ci.com/g/autorusltd/monolog-telegram-handler/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/autorusltd/monolog-telegram-handler/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/autorusltd/monolog-telegram-handler/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/autorusltd/monolog-telegram-handler/?branch=master)
[![Total Downloads](https://poser.pugx.org/arus/monolog-telegram-handler/downloads)](https://packagist.org/packages/arus/monolog-telegram-handler)
[![Latest Stable Version](https://poser.pugx.org/arus/monolog-telegram-handler/v/stable)](https://packagist.org/packages/arus/monolog-telegram-handler)
[![License](https://poser.pugx.org/arus/monolog-telegram-handler/license)](https://packagist.org/packages/arus/monolog-telegram-handler)---
## Installation (via composer)
```bash
composer require 'arus/monolog-telegram-handler:^2.1'
```## How to use?
```php
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
```php
$logger->debug('Hello, world!', [
'photo' => 'https://example.com/photo.jpeg',
]);
```#### Send an animation
```php
$logger->debug('Hello, world!', [
'animation' => 'https://example.com/animation.gif',
]);
```#### Send a video
```php
$logger->debug('Hello, world!', [
'video' => 'https://example.com/video.mp4',
]);
```### Set custom API URL (relevant for Russia)
#### Via API
```php
$sender->setUrl('https://proxy.api.telegram.example.com');
```#### Via environment
```php
putenv('TELEGRAM_URL=https://proxy.api.telegram.example.com');
```## Test run
Create your `phpunit.xml` file:
```bash
cp phpunit.xml.dist phpunit.xml
```Open your `phpunit.xml` file and set the following environment variables: `TELEGRAM_TOKEN` and `TELEGRAM_RECIPIENT`, then:
```bash
php vendor/bin/phpunit --colors=always --coverage-text
```## Useful links
* https://core.telegram.org/bots/api