va/smart-sms
Composer 安装命令:
composer require va/smart-sms
包简介
A package to send sms notification in laravel apps.
README 文档
README
Sms Notification service and channel for send sms with smartsms.ir
How to install and config va/smart-sms package?
Installation
composer require va/smart-sms
Publish Config file
php artisan vendor:publish --tag=smart-sms
Where is the config file? In config/smart-sms.php
'line_number' => env('SMS_LINE_NUMBER'),
'user_id' => env('SMS_USER_ID'),
'password' => env('SMS_PASSWORD'),
'default_sms_rcpt' => env('SMS_DEFAULT_SMS_RCPT'),
'mobile_field_name' => env('SMS_MOBILE_FIELD_NAME', 'mobile')
Set You're private configs in .env file, for example
SMS_LINE_NUMBER=10001010
SMS_USER_ID=12345
SMS_PASSWORD=123456789
SMS_DEFAULT_SMS_RCPT=0901***1020 // You're phone number for test on local mode or (.env => APP_ENV=local)
SMS_MOBILE_FIELD_NAME=mobile // Name of the mobile field in you're User model or users migration or users table
How to use va/smart-sms package?
Default Facade for send message and it's methods
// The default message:
$message = 'You're message;
// If we want to send a message to $user:
$user->notify(SmsNotificationFacade::message($message)); // mobile = $user->mobile, message = $message
or
$request->user->notify(SmsNotificationFacade::message($message)); // mobile = $user->mobile, message = $message
// If we want to send a mesage to another mobile number:
$user->notify(SmsNotificationFacade::message($message)->mobile('0901***1020')); // mobile = 0901***1020, message = $message
// If we want to send a message to another mobile numbers (Send Group message):
$user->notify(SmsNotificationFacade::message($message)->group(['0901***1020', '0901***3040']));
Create a custom sms notification and use this
-
Make a new notification
php artisan make:sms-notification SendActivationNotification -
In which directory was this class made?
app/Notifications/Message/SendActivationNotification.php -
Content of this Notification
<?php namespace App\Notifications\Message; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Va\SmartSms\Channels\SmartSmsChannel; class SendActivationNotification extends Notification { use Queueable; public $message; public $mobile; public $group; /** * SendActivationNotification constructor. * @param string|null $message * @param string|null $mobile * @param array $group */ public function __construct(string $message = null, string $mobile = null, array $group = []) { $this->message = $message; $this->mobile = $mobile; $this->group = $group; } /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [SmartSmsChannel::class]; } public function toChannel() { return [ 'text' => "You're message" OR $this->message, // You're default (text of message) 'mobile' => $this->mobile, 'group' => $this->group ]; } } -
Use this Notification for send message
// If we want to send a message with this notification $user->notify(new SendActivationNotification()); // mobile = $user->mobile, message = (Default meassge in notification) // If we want to send a message to another mobile number: $user->notify(new SendActivationNotification(null, '0901***1020')); // mobile = $user->mobile, message = (Default meassge in notification) // If we want to send a message to another mobile numbers (Send Group message): $user->notify(new SendActivationNotification(null, null, ['0901***1020', '0901***3040'])); // mobile = array, message = (Default meassge in notification) // If we want to push a message to notification class $message = "You're message"; $user->notify(new SendActivationNotification($message)); // mobile = $user->mobile, message = $message
va/smart-sms 适用场景与选型建议
va/smart-sms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 120 次下载、GitHub Stars 达 6, 最近一次更新时间为 2020 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「sms」 「notification」 「laravel」 「iranian」 「laravel7」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 va/smart-sms 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 va/smart-sms 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 va/smart-sms 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package makes it easy to send notifications via AfricasTalking with Laravel
Apple Push Notification & Feedback Provider
Throttle notifications on a per-channel basis
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
Simple javascript toast notifications
统计信息
- 总下载量: 120
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-13