deslynx/alert-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

deslynx/alert-bundle

Composer 安装命令:

composer require deslynx/alert-bundle

包简介

Send alert email service and specialized Monolog handler

README 文档

README

Latest stable version License PHPStan Enabled PHPStan Level max

Installation

Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.

Applications that use Symfony Flex

Open a command console, enter your project directory and execute:

composer require deslynx/alert-bundle

Applications that don't use Symfony Flex

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

composer require deslynx/alert-bundle

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:

// config/bundles.php

return [
    // ...
    DesLynx\AlertBundle\DesLynxAlertBundle::class => ['all' => true],
];

Configuration

# /config/packages/deslynx_alert.yaml
deslynx_alert:

    # The sender of the email, like "Name <email@address.com>" or a simple email.
    from: ~ # Required

    # A list of always added recipients for the email, like "Name <email@address.com>" or a simple email.
    to: [] # Required

    # Your project name. Included in the email subject
    projectName: 'My project'

    # If you want to use a custom email transport set this to the name of the transport.
    transport: null

# If you need another configuration for specific environments you can overwrite some configs
#when@dev:
#  deslynx_alert:
#    from: ~
#    to: []
#    projectName: 'My project'
#    transport: null

Important note

This bundle rely on the Symfony Mailer component for sending email so be sure to have it configured.

Usage (service)

This bundle provide a single service for sending an alert email which you can autowire by using the AlertHelper type-hint:

// src/Controller/SomeController.php

use DesLynx\AlertBundle\Service\AlertHelper;
//...

class SomeController
{
    public function index(AlertHelper $alertHelper) {
        $alertHelper->sendAlert(
            'A significant subject.',
            'A significant message. Either text or HTML.',
            false, // Optional. Set to true if the message is HTML
            ['email1@address.com', 'email2@address.com' /*, ...*/] // Optional. A list of recipients to add in cc in addition to the globally defined recipients (see configuration)
         );
    }    
}

Usage (Monolog Handler)

This bundle provide a Monolog Handler using the AlertHelper service. It allows to add a monolog handler config to send an alert email with the full log stack on every critical error happening in the project.

To enable this functionality, require the MonologBundle if not already done then just add this to your monolog config:

# config/packages/monolog.yaml
monolog:
  handlers:
    # ...
    deslynx_critical:
      type: fingers_crossed
      action_level: critical
      handler: deslynx_deduplicated
    deslynx_deduplicated:
      type: deduplication
      handler: deslynx_alert_mailer
    deslynx_alert_mailer:
      type: service
      id: DesLynx\AlertBundle\Monolog\Handler\AlertMailerHandler
      level: debug

deslynx/alert-bundle 适用场景与选型建议

deslynx/alert-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 49 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 deslynx/alert-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 deslynx/alert-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 deslynx/alert-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 49
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-08