nqxcode/laravel-exception-notifier
Composer 安装命令:
composer require nqxcode/laravel-exception-notifier
包简介
Notify about exception in laravel project via telegram and email
README 文档
README
Notify about exception in laravel project via telegram and email.
Notification attachment contains gzipped html with exception dump that rendered with facade/ignition, for example:
Installation
Require this package in your composer.json:
composer require "nqxcode/laravel-exception-notifier"
Configuration
Publish the config file into your project by running:
php artisan vendor:publish --provider="Nqxcode\LaravelExceptionNotifier\ServiceProvider"
Change default config file config/laravel-exception-notifier.php, for example remove unnecessary channel:
<?php return [ 'routes' => [ [ 'channel' => 'mail', 'route' => env('EXCEPTION_NOTIFIER_EMAIL', 'example@gmail.com'), ], [ 'channel' => 'telegram', 'route' => env('EXCEPTION_NOTIFIER_TELEGRAM_USER_ID', '1234567890') ] ], 'subject' => 'Исключение на сайте '.env('APP_URL'), ];
Add to config/services.php following:
<?php return [ // ... 'telegram-bot-api' => [ 'token' => env('TELEGRAM_BOT_TOKEN'), ] ];
In .env add correct environment variables:
# For email notification EXCEPTION_NOTIFIER_EMAIL=test@test.com # For telegram notification # recipient EXCEPTION_NOTIFIER_TELEGRAM_USER_ID=423460522 # sender TELEGRAM_BOT_TOKEN=1160101879:AAFzuda0o7X6Dp4RBp00K-7dYjjnwMY887A
To get telegram bot token create new bot in BotFather with this action /newbot, see more details here.
To notify about exception for production environment in file app/Exceptions/Handler.php modify report method:
<?php namespace App\Exceptions; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Nqxcode\LaravelExceptionNotifier\ExceptionNotifierInterface; use Throwable; class Handler extends ExceptionHandler { // ... public function report(Throwable $exception) { if ($this->container->isProduction() && $this->shouldReport($exception)) { $this->container->make(ExceptionNotifierInterface::class)->notify($exception); } parent::report($exception); } // ... }
License
Package licenced under the MIT license.
统计信息
- 总下载量: 256
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-10
