macellan/netgsm
Composer 安装命令:
composer require macellan/netgsm
包简介
Netgsm SMS notification channel for Laravel
README 文档
README
This package makes it easy to send sms notifications using Netgsm with Laravel 10.x, 11.x, 12.x
Contents
Installation
You can install this package via composer:
composer require macellan/netgsm
Setting up the Netgsm service
Add your Netgsm configs to your config/services.php:
// config/services.php ... 'sms' => [ 'netgsm' => [ 'username' => env('NETGSM_USERNAME', ''), 'password' => env('NETGSM_PASSWORD', ''), 'header' => env('NETGSM_HEADER', ''), 'language' => env('NETGSM_LANGUAGE', 'tr'), 'enable' => env('NETGSM_ENABLE', false), 'debug' => env('NETGSM_DEBUG', false), // Will log sending attempts and results 'sandbox_mode' => env('NETGSM_SANDBOX_MODE', false), // Will not invoke API call ], ], ...
Usage
You can use the channel in your via() method inside the notification:
use Illuminate\Notifications\Notification; use Macellan\Netgsm\DTO\Sms\BaseSmsMessage; use Macellan\Netgsm\DTO\Sms\SmsMessage; class TestNotification extends Notification { public function via($notifiable) { return ['netgsm']; } public function toNetgsm(object $notifiable): BaseSmsMessage { return new SmsMessage('Netgsm test message'); } }
For Otp Sms sending, OtpSmsMessage class can be returned.
return new OtpSmsMessage('Netgsm otp test message');
In your notifiable model, make sure to include a routeNotificationForSms() method, which returns a phone number.
public function routeNotificationForSms() { return $this->phone; }
On-Demand Notifications
Sometimes you may need to send a notification to someone who is not stored as a "user" of your application. Using the Notification::route method, you may specify ad-hoc notification routing information before sending the notification:
Notification::route('sms', '+905554443322') ->notify(new TestNotification());
Usage With Facade
use Macellan\Netgsm\Facades\Netgsm; use Macellan\Netgsm\DTO\Sms\SmsMessage; use Macellan\Netgsm\DTO\Sms\OtpSmsMessage; // Sms send - single sms $smsMessage = (new SmsMessage('Netgsm test message')) ->setNumbers(['+905554443322']); Netgsm::sendSms($smsMessage); /** // return array [ 'code' => '00', // Netgsm response code 'id' => '17377215342605050417149344', // Job id, 'description" => 'queued', ] **/ // Sms send - bulk sms with same message $smsMessage = (new SmsMessage('Netgsm test message')) ->setNumbers(['+905554443322', '+905554443333']); Netgsm::sendSms($smsMessage); // Sms send - bulk sms $smsMessage = (new SmsMessage) ->setNumbers(['+905554443322', '+905554443333']) ->setMessages(['Message 1', 'Message 2']); Netgsm::sendSms($smsMessage); // Otp Sms send $otpSmsMessage = (new OtpSmsMessage('Netgsm otp test message')) ->setNumbers(['+905554443322']); Netgsm::sendSms($otpSmsMessage); /** // return array [ 'code' => '00', // Netgsm response code 'id' => '111111', // Job id 'error' => '', // Error message ] **/
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Credits
macellan/netgsm 适用场景与选型建议
macellan/netgsm 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 06 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sms」 「notification」 「laravel」 「netgsm」 「macellan」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 macellan/netgsm 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 macellan/netgsm 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 macellan/netgsm 相关的其它包
同方向 / 同关键字的高下载量 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
统计信息
- 总下载量: 5k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-07