nikajorjika/laravel-sms-office
Composer 安装命令:
composer require nikajorjika/laravel-sms-office
包简介
Package that servers as a channel provider for Georgian SMS office web service
README 文档
README
nikajorjika/laravel-sms-office is a support package for smsoffice.ge.
Installation
Use composer php package manager to install nikajorjika/laravel-sms-office.
composer require nikajorjika/laravel-sms-office
Adding Variables in .env file
# for testing purposes you can also use SMS_OFFICE_DRIVE=log
SMS_OFFICE_DRIVER=sms-office
SMS_OFFICE_KEY=[api-key-provided-by-smsoffice.ge]
SMS_OFFICE_FROM=[sender-name]
SMS_OFFICE_NOSMS=[no-sms-code-provided-by-smsoffice.ge]
To further customize and configure package we first need to publish our config file:
php artisan vendor:publish --provider="Nikajorjika\SmsOffice\SmsOfficeServiceProvider" --tag="config"
this will publish smsoffice.php file inside our config folder:
<?php return [ /** * Endpoint for sms office url */ 'api_url' => env('SMS_OFFICE_URL', 'http://smsoffice.ge/api/v2/send/'), /** * Private Key provided by sms office service */ 'key' => env('SMS_OFFICE_KEY', null), /** * Driver that serves as a channel driver for laravel */ 'driver' => env('SMS_OFFICE_DRIVER', 'sms-office'), /** * This key defines sender name * for the sms to be delivered from */ 'from' => env('SMS_OFFICE_FROM', NULL), /** * List of drivers that sms office package supports */ 'supported_drivers' => ['sms-office', 'log'], /** * Define no sms code for the user to unsubscribe */ 'no_sms_code' => env('SMS_OFFICE_NOSMS', NULL), ];
Usage
There are two ways to use this package.
As a Facade
<?php // Basic Usage ... use Nikajorjika\SmsOffice\Facades\SmsOffice; $phoneNumber = '855737812'; // It could also be 995855737812 $message = 'You have found your package ;).'; SmsOffice::message($message)->to($phoneNumber)->send();
As a Channel
To start off, we need to include SmsOfficeChannel::class in via channels array and implement our version of toSms function as shown below.
<?php ... use Nikajorjika\SmsOffice\SmsOfficeChannel; class FooBarNotification extends Notification implements ShouldQueue { use Queueable; ... /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [SmsOfficeChannel::class]; } /** * Return message to send via SmsOffice Channel * * @param mixed $notifiable * @return string $message */ public function toSms($notifiable) { return 'You have found your package ;).'; }
and inside our notifiable model, User in this case, we should implement routeNotificationForSms method, like so:
... use Illuminate\Notifications\Notifiable; class User extends Authenticatable { use Notifiable; /** * Get phone number from notifiable model * * @return string */ public function routeNotificationForSms() { return $this->full_phone_number; }
that's it now we will be able to send notifications via additional SmsOffice channel.
Package Configuration
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
nikajorjika/laravel-sms-office 适用场景与选型建议
nikajorjika/laravel-sms-office 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.73k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 nikajorjika/laravel-sms-office 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nikajorjika/laravel-sms-office 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.73k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-29