PHPackages                             mani/yii2-twiliosms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. mani/yii2-twiliosms

ActiveYii2-extension[Mail &amp; Notifications](/categories/mail)

mani/yii2-twiliosms
===================

Twilio sms for sending otp messages to the users

1.0.6(8y ago)218BSD-3-ClausePHP

Since Sep 15Pushed 8y ago1 watchersCompare

[ Source](https://github.com/manikvm/yii2-sms)[ Packagist](https://packagist.org/packages/mani/yii2-twiliosms)[ RSS](/packages/mani-yii2-twiliosms/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (7)DependenciesVersions (8)Used By (0)

Twilio SMS
==========

[](#twilio-sms)

Twilio sms for sending otp messages to the users

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist rbt/yii2-twiliosms "*"

```

or add

```
"rbt/yii2-twiliosms": "*"

```

to the require section of your `composer.json` file.

Configuration
-------------

[](#configuration)

To use this extension, you have to configure the class and twilio account details in your application configuration: return\[ 'components' =&gt; \[ 'smsotp' =&gt;\[ 'class' =&gt; '\\twiliosms\\sms\\Smssendotp',

```
            //Twilio Test credentials
            'Test_Account_id' => 'xxxxxxxxxxxxxxx',
            'Test_Auth_Token' => 'xxxxxxxxxxxxxxx',
            'Test_From_Number' => 'xxxxxxxxxxxxxxx',

            //Twilio Live credentials

            'Live_Account_id'  => 'xxxxxxxxxxxxxxx',
            'Live_Auth_Token'  => 'xxxxxxxxxxxxxxx',
            'Live_From_Number' => 'xxxxxxxxxxxxxxx',
	    //Here specify the mode whether it is live or test
            'Send_Otp_Mode' => 'test',

	    // If it is US use +1
            'Phone_Country_Code' => '+91'
    	],
    ],
]

```

Usage
-----

[](#usage)

Once the extension is installed, follow the below steps to send an otp number to the given phone number and save the otp code into database.

Step 1: Run the below query in your database.

```
	CREATE TABLE IF NOT EXISTS `sendsms` (
	  `id` int(11) NOT NULL,
	  `phone_number` varchar(15) DEFAULT NULL,
	  `otp_number` varchar(6) DEFAULT NULL,
	  `status` tinyint(4) NOT NULL DEFAULT '0'
	) ENGINE=InnoDB DEFAULT CHARSET=utf8;

	ALTER TABLE `sendsms` ADD PRIMARY KEY (`id`);

	ALTER TABLE `sendsms` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

```

Step 2: Generate model Sendsms.php for the table `sendsms`.

Step 3: Create view file sendotp.php file in views/site folder.

```

```

Step 4: Create one function like actionSendotp() in site controller.

```
