2017 © Pedro Peláez
 

yii2-extension yii2-twilio-component

A Yii2 Application Component to ease the use of twilio SDK

image

2amigos/yii2-twilio-component

A Yii2 Application Component to ease the use of twilio SDK

  • Friday, October 27, 2017
  • by tonydspaniard
  • Repository
  • 3 Watchers
  • 3 Stars
  • 775 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 2 Versions
  • 59 % Grown

The README.md

Twilio Application Component for Yii2

Latest Version Software License Total Downloads, (*1)

Twilio is an awesome service that allows to include programmable SMS, Voice, Video, and Chat services in your apps. For Server side only Voice and SMS services are available., (*2)

This component is a simple wrapper to ease Yii2 framework developers the job to send SMS and start Voice calls with Twilio., (*3)

Install

Via Composer, (*4)

$ composer require 2amigos/yii2-twilio-component

Usage

Sign up for a Twilio Account

To use the Twilio REST API, you need an account. Signing up for a free Twilio account is easy. Once you've signed up, head over to your Console and grab your Account SID and your Auth Token., (*5)

Purchase an SMS Capable Phone Number

Sending SMS messages requires an SMS capable phone number. You can browse the available phone numbers in the Console. Be sure that the phone number you buy is SMS capable. When you search, you can check the box to filter available numbers to those that are SMS capable., (*6)

Once you have the Twilio phone number you are ready to configure your application component., (*7)

Configuring the Component

You have to take the Account SID, the Auth Token and the purchased phone number and configure the component:, (*8)

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

Sending an SMS

Now that the application component has been set, you can do the following to send SMS:, (*9)


$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;

In case you wish to use another purchased phone number, you can override the one configured as follows:, (*10)


$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;

Using code fixer

We have added a PHP code fixer to standardize our code. It includes Symfony, PSR2 and some contributors rules., (*11)

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

Why there are no tests?

The component is too simple to include tests as its a wrapper to Twilio's client library and the library has already all the required tests to check the functionality., (*12)

Contributing

Please see CONTRIBUTING for details., (*13)

Credits

License

The BSD License (BSD). Please see License File for more information., (*14)


Custom Software | Web & Mobile Development
www.2amigos.us

The Versions

27/10 2017

dev-master

9999999-dev

A Yii2 Application Component to ease the use of twilio SDK

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

yii2 sms 2amigos yii yii 2 yii framework voice twilio

27/10 2017

1.0.0

1.0.0.0

A Yii2 Application Component to ease the use of twilio SDK

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

yii2 sms 2amigos yii yii 2 yii framework voice twilio