定制 matperez/yii2-sms-sender 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

matperez/yii2-sms-sender

Composer 安装命令:

composer create-project matperez/yii2-sms-sender

包简介

Yii2 SMS sender

关键字:

README 文档

README

Build Status Coverage Status

Yii2 SMS Sender

Setup

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist matperez/yii2-sms-sender

or add

"matperez/yii2-sms-sender": "*"

to the require section of your composer.json file.

Dev environment

'components' = [
  'sms' => [
    'viewPath' => '@app/sms',
    'class' => \matperez\yii2smssender\components\Sender::class,
    'transportConfig' => [
      'class' => \matperez\yii2smssender\transports\FileTransport::class, 
    ],
  ],
],

Production environment

Using https://integrationapi.net

'components' = [
  'sms' => [
    'viewPath' => '@app/sms',
    'class' => \matperez\yii2smssender\components\Sender::class,
    'transportConfig' => [
      'class' => \matperez\yii2smssender\transports\IntegrationApiTransport::class,
      'login' => 'login',
      'password' => 'password',
    ],
  ],
],

Place this somewhere in a bootstrap file

\Yii::$container->set(\GuzzleHttp\ClientInterface::class, function() {
  return new \GuzzleHttp\Client();
});

Usage

Composing a message

The message can be composed from a template. The template name could be relative to viewPath or it could be a full path to a the view. Yii aliases are acceptable.

$message = Yii::$app->sms->compose('template_name', $params);
$message = Yii::$app->sms->compose('@app/sms/template_name', $params);

It is also possible to compose an empty message when no view name provided

$message = Yii::$app->sms->compose();

Middleware

The message can be preprocessed prior to sending. For example log or modify its content. Middleware should be set as an array of callable.

'components' = [
  'sms' => [
      'class' => \matperez\yii2smssender\components\Sender::class,
      'middleware' => [
          function(\matperez\yii2smssender\interfaces\IMessage $message) {
              $message->setMessage('new message content');
          }
      ]
  ],
],

Sending a message

$message = Yii::$app->sms->compose('some-view', $params);
$message->setTo('1234345456');
$message->setFrom('sender');
$message->send();

Balance checking

if (Yii::$app->sms->canFetchBalance()) {
  $balance = Yii::$app->sms->getBalance();
}

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固