leonis/easysms-notification-channel 问题修复 & 功能扩展

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

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

leonis/easysms-notification-channel

最新稳定版本:3.0.0

Composer 安装命令:

composer require leonis/easysms-notification-channel

包简介

EasySms Notification Channel for Laravel.

README 文档

README

使用 overtrue/easy-sms 发送 Laravel 消息通知。

安装

composer require leonis/easysms-notification-channel

配置

  1. 在 config/app.php 注册 ServiceProvider (Laravel 5.5 + 无需手动注册):

    'providers' => [ // ... Leonis\Notifications\EasySms\EasySmsChannelServiceProvider::class, ],
  2. 创建配置文件:

    php artisan vendor:publish --provider="Leonis\Notifications\EasySms\EasySmsChannelServiceProvider"
  3. 修改应用根目录下的 config/easysms.php 中对应的参数即可。

使用

  1. 创建通知:

    <?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Leonis\Notifications\EasySms\Channels\EasySmsChannel; use Leonis\Notifications\EasySms\Messages\EasySmsMessage; class VerificationCode extends Notification { use Queueable; public function via($notifiable) { return [EasySmsChannel::class]; } public function toEasySms($notifiable) { return (new EasySmsMessage) ->setContent('您的验证码为: 6379') ->setTemplate('SMS_001') ->setData(['code' => 6379]); } }
  2. 向已绑定手机号用户发送通知。

    用户模型:

    <?php namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; use Overtrue\EasySms\PhoneNumber; class User extends Authenticatable { use Notifiable; public function routeNotificationForEasySms($notification) { return new PhoneNumber($this->number, $this->area_code); } }

    发送通知:

    // 使用 Notifiable Trait $user->notify(new VerificationCode()); // 使用 Notification Facade Notification::send($user, new VerificationCode());
  3. 向未注册用户或未绑定手机号用户发送通知。

    Notification::route( EasySmsChannel::class, new PhoneNumber(13333333333, 86) )->notify(new VerificationCode());

License

MIT

统计信息

  • 总下载量: 38.77k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 160
  • 点击次数: 2
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 159
  • Watchers: 3
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固