1. Go to this page and download the library: Download abergasov/telegram_logger 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/ */
abergasov / telegram_logger example snippets
const INFO_CHAT = 0;
const ERROR_CHAT = 1;
const CONTACT_CHAT = 2;
$logger = new TelegramLogger([
'token' => SET_YOUR_TOKEN_HERE,
'chats' => [
INFO_CHAT => -199024103,
ERROR_CHAT => -293646246,
CONTACT_CHAT => -305488244,
... add more or less if need
],
'trace_dir' => __DIR__ . '/trace/logs',
'decorate_url' => 'https://example.com/trace/logs',
'logs' => [
'access_log' => '/home/admin/web/my_site/logs/access_log.log',
'error_log' => '/home/admin/web/my_site/logs/error_log.log',
]
]);
$logger->addSlackConfig([
'token' => SET_YOUR_SLACK_TOKEN_HERE,
'channels' => [
INFO_CHAT => 'GF4UTEHGB',
ERROR_CHAT => 'GF4UTEHGB',
CONTACT_CHAT => 'GF4UTEHGB',
],
]);
$result = $logger->sendMessage(INFO_CHAT, 'Hello, I need help', 'Additional info 1', 'Additional info 2', 'Additional info 3');
echo ($result ? 'Info message was send' : 'Troubles in send messages') . PHP_EOL;
try {
throw new RuntimeException('Something went wrong in this world');
} catch (Throwable $t) {
$logger->sendMessage(ERROR_CHAT, 'Exception in script', $t);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.