andrebian/telegram-error-report

A simple tool to send error report over Telegram

dev-master 2021-04-05 14:27 UTC

This package is auto-updated.

Last update: 2024-11-05 22:11:09 UTC


README

Is a simple implementation of the Telegram bot to keep developers updated about applicationsĀ“ errors.

This is a code-level tool, which means that is useful mainly for developers.

With this implementation, the developer can receive exceptions, error 500, brute-force attempts, user cheating behavior, login failed attempts, etc. Use your imagination.

Installing

Type composer require andrebian/telegram-error-report or download the zip.

Tests

Copy file config/config.php.dist to config/config.php, set your bot and channel configuration and run ./vendor/bin/phpunit

Using

<?php

use Andrebian\TelegramErrorReport\TelegramErrorReport;

require __DIR__ . '/vendor/autoload.php';

// initializing
$telegramErrorReport = new TelegramErrorReport('YOUR_CHANNEL_ID_HERE', 'YOUR_BOT_ID_HERE');

// sending info message
$telegramErrorReport->sendInfoMessage('Your message');

// sending error message
$telegramErrorReport->sendErrorMessage('Your message');

// sending debug message
$telegramErrorReport->sendDebugMessage('Your message');


// Using with try/catch
try {
    // your stuff here
} catch (Exception $exception) {
    $message = $exception->getMessage();
    $message .= TelegramErrorReport::LINE_BREAK . $exception->getFile();
    $message .= ':' . $exception->getLine();
    $message .= TelegramErrorReport::LINE_BREAK . $exception->getTraceAsString();
    
    $telegramErrorReport->sendErrorMessage($message);
}

Contributing

You can open issues or fork this repository and make PR.

Sponsor