Download the PHP package mani/yii2-twiliosms without Composer

On this page you can find all versions of the php package mani/yii2-twiliosms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-twiliosms

Twilio SMS

Twilio sms for sending otp messages to the users

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json file.

Configuration

To use this extension, you have to configure the class and twilio account details in your application configuration: return[ 'components' => [ 'smsotp' =>[ 'class' => '\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

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.

        <div class="site-sendotp">

            <div class="alert alert-success">
                <?=Yii::$app->session->getFlash('successMessage')?>
            </div>

            <div class="alert alert-danger">
                <?=Yii::$app->session->getFlash('failureMessage')?>
            </div>

                <?= $form->field($model, 'phone_number')->textInput(['type'=>'text','class' => 'phone']); ?> 

                <div class="form-group">
                    <?= Html::submitButton('Send OTP', ['class' => 'btn btn-primary']) ?>
                </div>

        </div><!-- site-sendotp -->

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

    <?php
    namespace app\controllers;

    use Yii;
    use yii\filters\AccessControl;
    use yii\web\Controller;
    use yii\web\Response;
    use yii\filters\VerbFilter;
    use app\models\LoginForm;
    use app\models\ContactForm;
    use app\models\Sendsms;

    class SiteController extends Controller
    {

        /**
         * Displays send otp page.
         *
         * @return string
         */
        public function actionSendotp()
        {
            $model = new Sendsms();
            if (Yii::$app->request->post()) {
                $mobile_number = $_POST['Sendsms']['phone_number'];
                $otp_message_body = "Your Verification code is:";
                $send_otp_mode = Yii::$app->smsotp->Send_Otp_Mode;

                //Sending otp number to the given mobile number.
                $send_otp = \twiliosms\sms\Smssendotp::sendMessage($mobile_number,$otp_message_body,$send_otp_mode);
                //echo '<pre>';var_dump($send_otp);
                //exit;
                if ( $send_otp != false && $send_otp !='')
                {
                    $phone_exist = Sendsms::find ()->where ( [ 
                        'phone_number' => $mobile_number
                    ] )->one ();
                    //Checking phone number is already exist in database or not
                    if ($phone_exist)
                    {
                        //updating otp code in database.
                        $update_otp_number = Sendsms::findOne (['phone_number' => $mobile_number]);
                        $update_otp_number->otp_number = $send_otp;
                        if ($update_otp_number->update ( false )) {
                            Yii::$app->session->setFlash('successMessage', "Successfully sent an OTP to your enter phone number");
                        }
                        else{
                             Yii::$app->session->setFlash('failureMessage', "Some Internal server issue occured.");
                        }

                    }else{
                        //Inserting phone number and otp number to database.
                        $model->phone_number = $mobile_number;
                        $model->otp_number = $send_otp;
                        if ($model->save ( false )) {
                            Yii::$app->session->setFlash('successMessage', "Successfully sent an OTP to your enter phone number");
                        }else{
                            Yii::$app->session->setFlash('failureMessage', "Some Internal server issue occured.");
                        }
                    }
                }else{
                    Yii::$app->session->setFlash('failureMessage', "Unable to send OTP, please try again.!");

                }

            }
            return $this->render('sendotp',['model'=>$model] );
        }
    }

All versions of yii2-twiliosms with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mani/yii2-twiliosms contains the following files

Loading the files please wait ....