sms-assistent/laravel-sender
Composer 安装命令:
composer require sms-assistent/laravel-sender
包简介
Laravel provider for sending sms messages by SMS-assistent.by
README 文档
README
Sender - Laravel Provider for SMS-assistent.by
Installation
$ composer require sms-assistent/laravel-sender
Add to config/app.php in section aliases:
'Sender' => SmsAssistent\Sender\Sender::class,
Publish package files by running
php artisan vendor:publish --provider="SmsAssistent\Sender\SenderServiceProvider"
Config
To configure connection with SMS-assistent add these options to your .env:
SMS_ASSISTENT_USERAGENT={useragent, optional}
SMS_ASSISTENT_USERNAME={SMS-assistent login}
SMS_ASSISTENT_PASSWORD={API password}
SMS_ASSISTENT_SENDER_NAME={registered SMS sender name}
Usage
Now, if you have configured Queues, you can create a Job like this below in /App/Http/Jobs
<?php
namespace App\Jobs;
use SmsAssistent\Sender\Sender;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
class SendSMS implements ShouldQueue
{
use Queueable;
protected $to;
protected $text;
/**
* @param $to
* @param $text
*/
public function __construct($to, $text)
{
$this->to = $to;
$this->text = $text;
}
public function handle(Sender $sender)
{
$sender->sendOne($this->to, $this->text);
}
}
And after dispatch a new Job anywhere in your app like this
<?php
use App\Jobs\SendSMS;
class SampleController extends Controller
{
public function test()
{
// Example 1
$this->dispatch((new SendSms('+375295363600', 'Hello world!')));
// Example 2
dispatch(new SendSms('+375295363600', 'Hello world!'));
// Example 3
SendSms::dispatch('+375295363600', 'Hello world!');
}
}
License
This package is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-29