2017 © Pedro Peláez
 

extension twilavel

PHP Twilio for Laravel and Lumen

image

kevupton/twilavel

PHP Twilio for Laravel and Lumen

  • Sunday, May 6, 2018
  • by kevupton
  • Repository
  • 1 Watchers
  • 0 Stars
  • 24 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 4 % Grown

The README.md

Twilavel

Implementation of Laravel / Lumen Twilio, (*1)

composer require kevupton/twilavel

1. Install Service Provider

<?php
// add directly from the app 
$app->register(\Kevupton\Twilavel\Providers\TwilavelServiceProvider::class);

OR, (*2)

All service providers are registered in the config/app.php configuration file., (*3)

<?php

'providers' => [
    // Other Service Providers

    \Kevupton\Twilavel\Providers\TwilavelServiceProvider::class,
],

2. Configure

.env configuration, (*4)

TWILIO_LOG_OVERRIDE=false
TWILIO_TOKEN=your_token
TWILIO_SID=your_sid
TWILIO_FROM=SwagApp

Execute php artisan vendor:publish for the complete config file., (*5)

Config: twilio.php, (*6)

<?php

return array(

    // set to true to prevent the
    'log_override' => env('TWILIO_LOG_OVERRIDE', false),

    // Your Account SID and Auth Token from twilio.com/console
    'sid' => env('TWILIO_SID'),
    'token' => env('TWILIO_TOKEN'),

    // the default from which messages will be sent from
    'from' => env('TWILIO_FROM', 'Twilavel'),
);

3. Usage

Using the Facade, (*7)

<?php 

\Twilio::message(new \Kevupton\Twilavel\Messages\BasicMessage('+61 123 456 789', 'Custom Body', 'From'));

Using the helper functions, (*8)

<?php 

send_basic_message('+61 123 456 789', 'Custom Body', 'From');

Custom Message Example:, (*9)

<?php

namespace App\Twilio\Messages;

use \Kevupton\Twilavel\Messages\Message;
use App\Models\User;

class VerifyPhone extends Message {

    const FROM = '+61123456789';

    /** @var string custom verification code */
    private $code;

    public function __construct(User $user, $mobile = null)
    {
        // use mobile other use user mobile
        $number = $mobile?: $user->mobile;
        parent::__construct($number, self::FROM);

        // get a random code
        $this->code = $user->generateMobileVerificationCode($number);
    }

    public function getBody()
    {
        return 'Your verification code: ' . $this->code;
    }
}

Using Custom Message:, (*10)

<?php

send_message(new VerifyPhone($user, '+61123456789'));

5. Logging

You can choose to override sending API requests for development environment and just view them in the Log. Simply just set TWILIO_LOG_OVERRIDE=true in your .env., (*11)

Contributing

Feel free to make a pull request at any time. Any help is appreciated (Y), (*12)

The Versions

06/05 2018

dev-master

9999999-dev

PHP Twilio for Laravel and Lumen

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

laravel php lumen twilio twilio php

06/05 2018

v0.2.4

0.2.4.0

PHP Twilio for Laravel and Lumen

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

laravel php lumen twilio twilio php

22/01 2018

v0.2.3.1

0.2.3.1

PHP Twilio for Laravel and Lumen

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

laravel php lumen twilio twilio php

04/12 2017

v0.2.3

0.2.3.0

PHP Twilio for Laravel and Lumen

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

laravel php lumen twilio twilio php

03/12 2017

v0.2.2

0.2.2.0

PHP Twilio for Laravel and Lumen

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

laravel php lumen twilio twilio php

20/09 2017

v0.2

0.2.0.0

PHP Twilio for Laravel and Lumen

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

laravel php lumen twilio twilio php

20/09 2017

v0.2.1

0.2.1.0

PHP Twilio for Laravel and Lumen

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

laravel php lumen twilio twilio php

20/09 2017

v0.1.2

0.1.2.0

PHP Twilio for Laravel and Lumen

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

laravel php lumen twilio twilio php

20/09 2017

v0.1.1

0.1.1.0

PHP Twilio for Laravel and Lumen

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

laravel php lumen twilio twilio php

20/09 2017

v0.1

0.1.0.0

PHP Twilio for Laravel and Lumen

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

laravel php lumen twilio twilio php