Skip to content

This component is YII2 wrapper for Twilio PHP SDK.

Notifications You must be signed in to change notification settings

filipajdacic/yii2-twilio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

Twilio for Yii2

This component is YII2 wrapper for Twilio PHP SDK.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist filipajdacic/yii2-twilio "master@dev"

or add

"filipajdacic/yii2-twilio": "master@dev"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by putting this in your config:

'components' => array(
    ...
    'Yii2Twilio' => [
        'class' => 'filipajdacic\yiitwilio\YiiTwilio',
        'account_sid' => 'YOUR_TWILIO_ACCOUNT_SID_HERE',
        'auth_key' => 'YOUR_TWILIO_AUTH_KEY_HERE', 
    ],
    ...
);

After you have configured a component, you can use it for example in this way:

    $twilioService = Yii::$app->Yii2Twilio->initTwilio();

        try {
            $message = $twilioService->account->messages->create(
                "+12345678901", // To a number that you want to send sms
                array(
                "from" => "+12345678901",   // From a number that you are sending
                "body" => "Hello from my Yii2 Application!",
            ));
        } catch (\Twilio\Exceptions\RestException $e) {
                echo $e->getMessage();
        }

For more SDK functions and usage documentation feel free to visit official Twilio PHP SDK documentation section here.

Resources

This component on YiiFramework.com

Twilio.com

If you have any questions, feel free to ask.

About

This component is YII2 wrapper for Twilio PHP SDK.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages