2017 © Pedro Peláez
 

yii2-extension yii2-sms

Yii2 extension which allow send sms using multiply providers. Now available Nexmo provider

image

demmonico/yii2-sms

Yii2 extension which allow send sms using multiply providers. Now available Nexmo provider

  • Friday, November 18, 2016
  • by demmonico
  • Repository
  • 1 Watchers
  • 0 Stars
  • 63 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

Yii2 component - Sms Sender

Description

Yii2 component which allow simple send sms using multiply providers. Switching between providers supports using yii config file (better), (*1)

Configure

Common params

return [
    //...
    'components' => [
        //...
        'sms' => [
            'class' => 'demmonico\sms\Sender',
            'senderNumber' => 'name' or 'number',
            'provider' => [
                'class' => 'demmonico\sms\Nexmo',
                'apiKey' => '***',
                'apiSecret' => '***',
            ],
        ],
    ],
];

or DI, (*2)

$component = \Yii::createObject('demmonico\sms\Nexmo', [
    [
        'class' => 'demmonico\sms\Sender',
        'senderNumber' => 'name' or 'number',
        'provider' => [
            'class' => 'demmonico\sms\Nexmo',
            'apiKey' => '***',
            'apiSecret' => '***',
        ],
    ],
]);

or using config component's bootstrap method (see https://github.com/demmonico/yii2-config), (*3)

in config file, (*4)

return [
    //...
    'components' => [
        //...
        'sms' => [
            'class' => 'demmonico\sms\Sender',
            'senderNumber' => 'name' or 'number',
            'provider' => [
                'class' => 'demmonico\sms\Nexmo',
                'apiKey' => [
                    'component' => 'config',
                    'sms.Nexmo.apiKey',
                ],
                'apiSecret' => [
                    'component' => 'config',
                    'sms.Nexmo.apiSecret',
                ],
            ],
        ],
    ],
];

and in local params file, (*5)

return [
    //...
    'sms.Nexmo.apiKey' => '******',
    'sms.Nexmo.apiSecret' => '******',
];

Now available Nexmo provider only. But you can add any external class with your custom provider. New providers can be added by creating class, which will implements demmonico\sms\SmsProviderInterface and extends (optional) demmonico\sms\BaseProvider., (*6)

Debug params

For debug you can use redirect option and dummy option. They can use separately or together. If redirect option redirectNumber is set then all messages will be send to this number. If dummy option dummyNumbers is set and field $to matches to any of dummyNumbers elements then process send will be skip and all sms fields will be logged, (*7)

return [
    //...
    'components' => [
        //...
        'sms' => [
            //...
            'debug' => [
                'redirectNumber' => 'number',
                'dummyNumbers' => [
                    'number',
                    //...
                ],
            ],
        ],
    ],
];

Usage

Send sms

Yii::$app->sms->sendSms('Hello, world!', 'number');

or, (*8)

Yii::$app->sms->sendSms('Hello, world!', 'recipientNumber', 'senderNumber');

Numbers must be in E.164 format. Method returns number (integer) of sent sms., (*9)

Get account balance

Yii::$app->sms->getBalance();

Method returns balance value (float)., (*10)

Get account numbers

Yii::$app->sms->getNumbers();

Method returns array of numbers which are associate with account., (*11)

The Versions

18/11 2016

dev-master

9999999-dev https://github.com/demmonico/yii2-sms

Yii2 extension which allow send sms using multiply providers. Now available Nexmo provider

  Sources   Download

MIT

The Requires

 

by Dmitry demmonico

component extension yii2 sms yii nexmo send

18/11 2016

v1.0.2

1.0.2.0 https://github.com/demmonico/yii2-sms

Yii2 extension which allow send sms using multiply providers. Now available Nexmo provider

  Sources   Download

MIT

The Requires

 

by Dmitry demmonico

component extension yii2 sms yii nexmo send

07/09 2016

v1.0.1

1.0.1.0 https://github.com/demmonico/yii2-sms

Yii2 extension which allow send sms using multiply providers. Now available Nexmo provider

  Sources   Download

MIT

The Requires

 

by Dmitry demmonico

component extension yii2 sms yii nexmo send

04/08 2016

v1.0.0

1.0.0.0 https://github.com/demmonico/yii2-sms

Yii2 extension which allow send sms using multiply providers. Now available Nexmo provider

  Sources   Download

MIT

The Requires

 

by Dmitry demmonico

component extension yii2 sms yii nexmo send