PHP code example of codelikesuraj / lograh-php
1. Go to this page and download the library: Download codelikesuraj/lograh-php 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/ */
codelikesuraj / lograh-php example snippets
use Codelikesuraj\LograhPHP\Logger;
// initialize logger with your Telegram bot credentials
$logger = new Logger(
appName: "unique_name_to_identify_your_app",
botToken: "api_key_generated_from_your_telegram_bot",
chatId: "id_of_your_telegram_chat_or_channel_or_group"
);
try {
// code that may generate an exception
...
} catch (\Throwable $exception) {
// optional list of exceptions to be ignored
$logger->ignore([ExceptionA::class, ExceptionB::class]);
// send exception to Telegram using any
// of the following methods
$logger->reportAsText($exception);
$logger->reportAsJson($exception);
$logger->reportAsJsonWithStackTrace($exception);
// further processing
...
}
bash
$ composer