Skip to content

📱 Plugin to send SMS messages with Twilio Gateway.

License

Notifications You must be signed in to change notification settings

MayMeow/cakephp-twilio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CakephpTwilio plugin for CakePHP

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require maymeow/cakephp-twilio

Open your src/Application.php file and load module

//add into bootstrap function
$this->addPlugin('CakephpTwilio');

To load component add it to src/AppController.php for whole application or to any of your controllers by demand.

$this->loadComponent('CakephpTwilio.Twilio');

Configuration

This plugin using Twilio/SDK. To sending SMS, Twilio account is required. From your number management in settings recieve your SID and TOKEN and add following lines to your config file config/app_local.php:

[
//... other configuration

    /**
     * Twilio SMS gate configuration
     */
    'Twilio' => [
        /**
         * From: use mobile phone number or string A-Za-z1-0 max length 11 characters
         * @see https://www.twilio.com/docs
         */
        'From' => '_NUMBER_OR_TEXT_',
        'Sid' => '_YOUR_SID_',
        'Token' => '_YOUR_TOKEN_'
    ],

// ... end of file
];

How to use it

You can send message from any controller using Twilio component

use CakephpTwilio\Model\Message;

$this->Twilio
    ->send(new Message('PhoneNumber', "Text"));

if you want change from variable

$this->Twilio
    ->send(new Message('PhoneNumber', "Text", "NumberOrText"));