orajo/zf-sms-zilla

Laminas 模块,用于发送短信

v2.1.0 2023-08-25 09:33 UTC

This package is auto-updated.

Last update: 2024-09-25 11:57:15 UTC


README

用于发送短信的 Zend Framework 2 模块。本模块基于 https://github.com/Orajo/sms-zilla 库。

======

安装

使用 composer

{
    "require": {
        "orajo/zf-sms-zilla": "1.*"
    }
}

php composer.phar require orajo/zf-sms-zilla

记得在 application.config.php 中注册模块

'modules' => array(
  'Application',
  'ZfSmsZilla'
),

用法

public function smsAction() {
  /**
   * @var \ZfSmsZilla\Service\SenderService
   */
  $smsService = $this->getServiceLocator()->get('ZfSmsZillaService');
  $smsService->send('Lorem ipsum 1', ['+41759987654']);
  $smsService->send('Lorem ipsum 2', ['605123456', '509546985']);
  
  // if you need more, e.g.
  $sender = $smsService->getSender();
  $errors = $sender->getAdapter()->getErrors();
  $sender->setValidator(new SmsZilla\Validator\LibphonenumberValidator('US'));
}