定制 gsouillard/laravel-new-user-slack-notifier 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

gsouillard/laravel-new-user-slack-notifier

Composer 安装命令:

composer require gsouillard/laravel-new-user-slack-notifier

包简介

A Laravel package to send Slack notifications on user registration.

README 文档

README

A Laravel package to send Slack notifications when a new user registers on your application.

Installation

You can install the package via Composer:

composer require gsouillard/laravel-new-user-slack-notifier

Configuration

After installing the package, publish the configuration file:

php artisan vendor:publish --tag=config

This will create a configuration file named slack-new-user-notifier.php in your config directory.

Configuration Options

  • webhook_url: The Slack Webhook URL where the notifications will be sent. This should be set in your .env file as SLACK_NEW_USER_NOTIFIER_WEBHOOK_URL.
  • app_name: The name of your application, which will be included in the Slack notification. It defaults to the APP_NAME defined in your .env file, but you can override it in the configuration file.
  • event_to_listen: Determines which event to listen to. You can set this to Registered (default) or Verified to send notifications based on the specific event.

Example configuration:

return [
    'webhook_url' => env('SLACK_NEW_USER_NOTIFIER_WEBHOOK_URL', ''),
    'app_name' => env('APP_NAME', 'Your Application'), // Default: APP_NAME
    'event_to_listen' => env('SLACK_NEW_USER_NOTIFIER_EVENT', 'Registered'), // Default: Registered
];

Usage

This package works by listening to either the Registered or Verified events in Laravel. By default, it listens to the Registered event. You can change this by setting the event_to_listen configuration option.

In your EventServiceProvider, the package automatically registers the listener based on your configuration:

use YourNamespace\SlackNotifier\SlackNotifier;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Events\Verified;
use Illuminate\Support\Facades\Event;

class EventServiceProvider extends ServiceProvider
{
    public function boot()
    {
        parent::boot();

        $eventToListen = config('slack-new-user-notifier.event_to_listen', 'Registered');

        if ($eventToListen === 'Verified') {
            Event::listen(Verified::class, function ($event) {
                SlackNotifier::notify($event->user->email);
            });
        } else {
            Event::listen(Registered::class, function ($event) {
                SlackNotifier::notify($event->user->email);
            });
        }
    }
}

Example .env Configuration

In your .env file, add:

SLACK_NEW_USER_NOTIFIER_WEBHOOK_URL=https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX
APP_NAME=My Awesome App
SLACK_NEW_USER_NOTIFIER_EVENT=Registered

Set SLACK_NEW_USER_NOTIFIER_EVENT to Verified if you want to send notifications only after the user verifies their email.

Testing

To run the tests, you can use PHPUnit:

vendor/bin/phpunit

Commit Rules and Versioning

This project follows semantic versioning. When making changes, use the following commit message conventions to automatically update the package version:

  • Major Version Bump: For breaking changes, include bump:major in your commit message.
  • Minor Version Bump: For adding backward-compatible features, include bump:minor in your commit message.
  • Patch Version Bump: For backward-compatible bug fixes or minor improvements, include bump:patch in your commit message.

Example commit messages:

  • Fix critical issue bump:major
  • Add new feature bump:minor
  • Fix minor bug bump:patch

License

The MIT License (MIT). Please see License File for more information.

gsouillard/laravel-new-user-slack-notifier 适用场景与选型建议

gsouillard/laravel-new-user-slack-notifier 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 08 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 gsouillard/laravel-new-user-slack-notifier 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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