modulus/laravel-notification 问题修复 & 功能扩展

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

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

modulus/laravel-notification

Composer 安装命令:

composer require modulus/laravel-notification

包简介

A Laravel package for sending notifications via email, SMS, and push notifications

README 文档

README

A comprehensive Laravel package for sending notifications via Email, SMS (Twilio, Vonage), and push notifications (Firebase Cloud Messaging).

Features

  • Email notifications with customizable templates
  • SMS notifications via Twilio or Vonage
  • Push notifications via Firebase Cloud Messaging (FCM)
  • Simple, clean API
  • Customizable and extendable
  • Laravel integration with config publishing

Installation

You can install the package via composer:

composer require modulus/laravel-notification

Configuration

Publish the configuration file:

php artisan vendor:publish --provider="Modulus\Notification\Providers\NotificationServiceProvider" --tag="notification-config"

Optionally, you can publish the views:

php artisan vendor:publish --provider="Modulus\Notification\Providers\NotificationServiceProvider" --tag="notification-views"

Environment Configuration

Add the following variables to your .env file and set as needed:

# Email Configuration (Using Laravel's mail configuration)
MAIL_FROM_ADDRESS=your-email@example.com
MAIL_FROM_NAME="Your Name"

# SMS Configuration - Twilio
SMS_DRIVER=twilio
TWILIO_SID=your-twilio-sid
TWILIO_AUTH_TOKEN=your-twilio-auth-token
TWILIO_FROM_NUMBER=your-twilio-phone-number

# SMS Configuration - Vonage
# SMS_DRIVER=vonage
VONAGE_API_KEY=your-vonage-api-key
VONAGE_API_SECRET=your-vonage-api-secret
VONAGE_FROM_NUMBER=your-vonage-phone-number

# Push Notification - Firebase Cloud Messaging
FCM_SERVER_KEY=your-fcm-server-key

Usage

Send an Email

use Modulus\Notification\Facades\Notification;

// Basic email
Notification::email(
    'recipient@example.com',  
    'Welcome!',
    'Welcome to our platform',
    'https://example.com/path/to/image.jpg', // Optional image
    [                    
        'text' => 'Verify Email',  // Button text
        'url' => 'https://example.com/verify'  // Button URL
    ]  // Optional button
);

// Multiple recipients
Notification::email(
    ['user1@example.com', 'user2@example.com'],
    'Team Update',
    'Important update for the team',
);

// Custom email template
Notification::emailCustom(
    'notification::emails.order-confirmation', 
    'customer@example.com',                    
    'Order Confirmation - #12345',           
    'Thank you for your order! Here are your order details:', 
    [
        'company_logo' => 'https://yourcompany.com/logo.png',
        'company_name' => 'Your Company',
        'company_email' => 'support@yourcompany.com',
        'company_phone' => '+1 (555) 123-4567',
        'order_url' => 'https://yourcompany.com/orders/12345',
        'order' => [
            'number' => '12345',
            'items' => [
                [
                    'name' => 'Product 1',
                    'quantity' => 2,
                    'price' => 29.99
                ],
                [
                    'name' => 'Product 2',
                    'quantity' => 1,
                    'price' => 49.99
                ]
            ],
            'total' => 109.97,
            'shipping_address' => [
                'street' => '123 Main St',
                'city' => 'New York',
                'state' => 'NY',
                'zip' => '10001',
                'country' => 'United States'
            ]
        ]
    ]
);

Send an SMS

use Modulus\Notification\Facades\Notification;

// Send SMS to a single recipient
Notification::sms(
    '+1234567890',
    'OTP Code',
    'Your verification code is: 123456'
);

// Send to multiple recipients
Notification::sms(
    ['+1234567890', '+0987654321'],
    'Sale Alert',
    'Our annual sale starts tomorrow! Use code SUMMER20 for 20% off.'
);

Send a Push Notification

use Modulus\Notification\Facades\Notification;

// Send FCM notification to a single device
Notification::realtime(
    'fcm-device-token-here',
    'New Message',
    'You have received a new message from John',
    'https://example.com/path/to/image.jpg' // Optional image
);

// Send to multiple devices
Notification::realtime(
    ['device-token-1', 'device-token-2'],
    'Breaking News',
    'Check out the latest updates on our platform'
);

Creating Custom Email Templates

  1. Publish the package views
  2. Create a new Blade template in resources/views/vendor/notification/emails/
  3. Use the template in your code:
Notification::emailCustom(
    'notification::emails.your-custom-template',
    'recipient@example.com',
    'Email Subject',
    'Email Body',
    [
        // Additional data that will be available in your template
    ]
);

License

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

modulus/laravel-notification 适用场景与选型建议

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

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

围绕 modulus/laravel-notification 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-08