escolalms/templates-sms 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

escolalms/templates-sms

最新稳定版本:0.1.12

Composer 安装命令:

composer require escolalms/templates-sms

包简介

Escola Headless LMS Templates for sms

README 文档

README

codecov Tests PHPUnit in environments downloads downloads downloads

What does it do

Package for sms notifications with editable templates (for important user-related events). This package supports sending sms via twilio.

Installing

  • composer require escolalms/templates-sms
  • php artisan db:seed --class="EscolaLms\Templates-SMS\Database\Seeders\TemplateSmsSeeder"

Configuration

You can configure the connection to Twilio through keys in the .env file:

  • TWILIO_SID - twilio SID unique key
  • TWILIO_TOKEN - twilio auth token
  • TWILIO_FROM - twilio phone number
  • TWILIO_SSL_VERIFY - twilio ssl verify

You can also change the default driver in SMS_DRIVER

Example

Sending SMS

Sending an SMS using the Sms facade

Sms::driver('twilio')->send('123456789', 'SMS message');

or

Sms::send('123456789', 'SMS message');

Custom driver

You can define your own driver for sending sms. The driver must implement the interface \EscolaLms\TemplatesSms\Drivers\Contracts\SmsDriver.

interface SmsDriver
{
    public function send(string $to, string $content, array $mediaUrls = [], array $params = []): bool;
}

Example custom driver:

class CustomDriver implements \EscolaLms\TemplatesSms\Drivers\Contracts\SmsDriver
{
    public function send(string $to, string $content, array $mediaUrls = [], $params = []): bool
    {
        // Implement send() method.
    }
}

Register a new driver, we would do the following:

Sms::extend('custom', function($app) {
    return new CustomDriver($app);
});

Tests

Run ./vendor/bin/phpunit to run tests. See tests folder as it's quite good staring point as documentation appendix.

codecov Tests PHPUnit in environments

This package has a facade for testing. The Sms facade's fake method allows you to easily a fake sms driver.

public function testSms() {
    Sms::fake();
    ...
    $service->sendSms($phone1);
    ...
    Sms::assertSent($phone1);
    Sms::assertNotSent($phone2);
}
public function testSms() {
    Sms::fake();
    ...
    Sms::assertSent($phone1, fn($sms) => $sms->content === 'Sms message');
}

统计信息

  • 总下载量: 9.65k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固