承接 nqxcode/laravel-exception-notifier 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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:

Screenshot_2020-11-12 🧨 Token could not be parsed from the request

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固