PHP code example of 2amigos / yii2-twilio-component

1. Go to this page and download the library: Download 2amigos/yii2-twilio-component library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

2amigos / yii2-twilio-component example snippets

 
// On your application config file 
// ... 
'components' => [
    'twilio' => [
        'class' => '\dosamigos\twilio\TwilioComponent',
        'sid' => 'ACCOUNT_SID',
        'token' => 'AUTH_TOKEN',
        'phoneNumber' => 'PURCHASED_PHONE_NUMBER'
    ]
]
 

$message = Yii::$app->twilio->sms('VALID_PHONE_NUMBER_TO_SEND_SMS', 'Hello World!');

// It returns a \Twilio\Rest\Api\V2010\Account\MessageInstance
echo $message->sid;

 

$message = Yii::$app->twilio->sms('VALID_PHONE_NUMBER_TO_SEND_SMS', 'Hello World!', [
 'from' => 'ANOTHER_PURCHASED_TWILIO_PHONE_NUMBER'
]);

// It returns a \Twilio\Rest\Api\V2010\Account\MessageInstance
echo $message->sid;

bash 
./vendor/bin/php-cs-fixer fix ./src --config .php_cs