granada-pride/unifonic-sms
Composer 安装命令:
composer require granada-pride/unifonic-sms
包简介
A Laravel package for integrating Unifonic SMS with the Laravel notification system.
README 文档
README
Unifonic SMS for Laravel
Unifonic SMS is a Laravel package that provides seamless integration with the Unifonic SMS service. It allows you to send SMS messages through the Unifonic platform using Laravel's native notification system. Whether you need to send OTPs, alerts, or marketing messages, this package simplifies the process by integrating directly into Laravel.
Features
- Seamless Integration: Easily send SMS notifications through Unifonic.
- Configurable: Adjust settings via the Laravel config system.
- Error Handling: Full support for exception handling and logging.
- Laravel Compatibility: Compatible with Laravel 8.x, 9.x, and 10.x.
- Secure: Handles sensitive data securely.
Table of Contents
Installation
To get started, install the package via Composer:
composer require granada-pride/unifonic-sms
Requirements
- PHP >= 8.0
- Laravel >= 8.x
Configuration
After installing the package, publish the configuration file:
php artisan vendor:publish --provider="GranadaPride\UnifonicSms\UnifonicSmsServiceProvider"
This will publish a unifonic.php configuration file to your config directory where you can set your AppSid, SenderID, and Endpoint.
Configuration Options
- AppSid: Your Unifonic application SID.
- SenderID: The name or number that will appear as the sender of the SMS.
- Endpoint: The Unifonic API endpoint (default: https://el.cloud.unifonic.com/rest/SMS/messages).
Example configuration (config/unifonic.php):
return [ 'appsId' => env('UNIFONIC_APP_SID', 'your-app-sid'), 'senderId' => env('UNIFONIC_SENDER_ID', 'your-sender-id'), 'endpoint' => env('UNIFONIC_ENDPOINT', 'https://el.cloud.unifonic.com/rest/SMS/messages'), ];
To enable logging for the Unifonic SMS package, you can add a custom log channel in your config/logging.php file:
'channels' => [ // Other log channels... 'unifonic' => [ 'driver' => 'single', 'path' => storage_path('logs/unifonic.log'), 'level' => 'error', ], ],
This configuration ensures that Unifonic SMS logs are stored in a separate log file at storage/logs/unifonic.log and only logs messages with a severity level of error or higher.
Usage
After configuring the package, you can send SMS notifications:
use GranadaPride\UnifonicSms\Notifications\UnifonicSmsNotification; $phone = '1234567890'; $message = "Your verification code is 123456"; $user->notify(new UnifonicSmsNotification($phone, $message));
Advanced Usage
To customize the SMS further or handle different scenarios, you can modify the notification class:
use GranadaPride\UnifonicSms\Notifications\UnifonicSmsNotification; class CustomSmsNotification extends UnifonicSmsNotification { public function toSms($notifiable) { return [ 'phone' => $this->phone, 'message' => "Your custom message", ]; } } // Sending the custom SMS $user->notify(new CustomSmsNotification($phone, $message));
Contributing
Contributions are welcome! Please feel free to submit a Pull Request or open an issue to improve this package.
License
This package is open-source software licensed under the MIT License. Please see the License File for more information.
granada-pride/unifonic-sms 适用场景与选型建议
granada-pride/unifonic-sms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 723 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 08 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 granada-pride/unifonic-sms 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 granada-pride/unifonic-sms 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 723
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-12