zafarjonovich / yii-telegram-error-handler
There is no license information available for the latest version (0.1.5) of this package.
YiiTelegramErrorHandler
Package info
github.com/zafarjonovich/YiiTelegramErrorHandler
pkg:composer/zafarjonovich/yii-telegram-error-handler
0.1.5
2022-06-20 12:54 UTC
Requires
- php: >=7.0
- ext-json: *
- zafarjonovich/telegram: *
README
Installation
Assalomu aleykum. This component is for yii2 framework. You can use this component to send your exceptions to your telegram. It is very easy to use.
If you are creating a web application, you need to put the following code in config/web.php
<?php
$config = [
...
'components' => [
...
'errorHandler' => [
'class' => 'zafarjonovich\YiiTelegramErrorHandler\Web' ,
'telegram' => [
'bot_token' => '123456789:ABCKDFHJKSDHKSJHDFKDHF' ,
'chat_ids' => [123,234,456]
]
]
];
?>
If you are creating a console application, you need to put the following code in config / web.php
<?php
$config = [
...
'components' => [
...
'errorHandler' => [
'class' => 'zafarjonovich\YiiTelegramErrorHandler\Console' ,
'telegram' => [
'bot_token' => '123456789:ABCKDFHJKSDHKSJHDFKDHF' ,
'chat_ids' => [123,234,456]
]
]
];
?>
Set telegram message structure
You can change the structure of messages that go to the telegram. It is very easy to use.There are 4 placements here.
- {message} - exception message
- {file} - exception file
- {line} - exception line
- {code} - exception code
You set up your message structure as follows
<?php
$config = [
...
'components' => [
...
'errorHandler' => [
'class' => 'zafarjonovich\YiiTelegramErrorHandler\Console' ,
'telegram' => [
...
'message_structure' => "File: {file}\n\nLine: {line}"
]
]
];
?>
Typically, the following message structure consists of:
Message:>Message:>Message: {message}\n\nFile: {file}\n\nLine: {line}\n\nCode: {code}