2017 © Pedro Peláez
 

yii2-extension yii2-smser

sms for Yii2

image

yiier/yii2-smser

sms for Yii2

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 50 % Grown

The README.md

sms for Yii2

sms for Yii2, (*1)

Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist yiier/yii2-smser "*"

or add, (*5)

"yiier/yii2-smser": "*"

to the require section of your composer.json file., (*6)

Migrations

Run the following command, (*7)

$ php yii migrate --migrationPath=@yiier/smser/migrations/

Usage

Once the extension is installed, simply modify your application configuration as follows:, (*8)

<?php
return [
    // something code
    'components' => [
        'smser' => [
            'class' => 'yiier\smser\Smser',
            'config' => [
                'gateways' => [
                    // 云片网
                    'yunpian' => [
                        'api_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxx',
                    ],
                ],
            ]
        ]
    ]
];

More detail overtrue/easy-sms 使用, (*9)

Validator, (*10)

<?php
class SignupForm extends \yii\base\Model
{
    // something code
    public $verifyCode;

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            // something code
            // usage is Optional
            ['verifyCode', '\yiier\smser\validators\SmsCodeValidator', 'usage' => 'Signup'],
        ];
    }
}

send code && update code status, (*11)

<?php
// send code
Yii::$app->smser->send(18688888888, [
    'content'  => '您的验证码为: 1234',
    'template' => 'SMS_001',
    'data' => ['code' => 1234, 'usage' => 'Signup'], // or 'data' => ['code' => 1234],
]);

// update used status 
\yiier\smser\models\SmsLog::used(18688888888, 1234);

The Versions

14/06 2018

dev-master

9999999-dev

sms for Yii2

  Sources   Download

BSD-4-Clause

The Requires

 

extension yii2 sms

03/02 2018

v0.1.1

0.1.1.0

sms for Yii2

  Sources   Download

BSD-4-Clause

The Requires

 

extension yii2 sms

23/01 2018

v0.1

0.1.0.0

sms for Yii2

  Sources   Download

BSD-4-Clause

The Requires

 

extension yii2 sms