2017 © Pedro Peláez
 

symfony-bundle twilio-bundle

Symfony 3 / PHP 7 wrapper for the official Twilio SDK v5

image

blackford/twilio-bundle

Symfony 3 / PHP 7 wrapper for the official Twilio SDK v5

  • Monday, November 28, 2016
  • by mblackford
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,531 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 34 Forks
  • 1 Open issues
  • 13 Versions
  • 84 % Grown

The README.md

Symfony Twilio Bundle (for Twilio SDK v6)

About

A quick and easy way to use the Twilio SDK (version 6) in a Symfony based application. Support for PHP 8+, Symfony >= 5.4. For full documentation about how to use the Twilio Client, see the official SDK provided by Twilio., (*1)

This bundle is a small wrapper around the official sdk. It just adds the basic auth and configs and avoid that you have to configure your service.yaml manual., (*2)

If you are already using the symfony/notifier component, habe a look at twilio-notifier., (*3)

Thank you for the awesome work of Fridolin Koch who created the first version of this bundle, with support for version 4 of the SDK., (*4)

Installation

composer req blackford/twilio-bundle

Configuration

Add these 2 parameters in .env.local and set it to your twilio credentials. Please see Env-Variables for more details., (*5)

TWILIO_USER='!changeMe!'
TWILIO_PASSWORD='!changeMe!'

Add a new file config/packages/twilio.yml and copy and adjust the following content:, (*6)

blackford_twilio:

  # (Required) Username to authenticate with, typically your Account SID from www.twilio.com/user/account
  username: '%env(TWILIO_USER)%'

  # (Required) Password to authenticate with, typically your Auth Token from www.twilio.com/user/account
  password: '%env(TWILIO_PASSWORD)%'

  # (Optional) Account Sid to authenticate with, defaults to <username> (typically not required)
  # accountSid: 

  # (Optional) Region to send requests to, defaults to no region selection (typically not required)
  # region: 

Usage

Configure your Twilio-Account, (*7)

Provided services:, (*8)

Service Class
twilio.client \Twilio\Rest\Client

Inside a controller:

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Twilio\Rest\Client as TwilioClient;

class TestController extends Controller
{
    public function __construct(private TwilioClient $twilioClient)
    {}

    public function smsAction()
    {
        $date = date('r');

        $message = $this->twilioClient->messages->create(
            '+12125551234', // Text any number
            array(
                'from' => '+14085551234', // From a Twilio number in your account
                'body' => "Hi there, it's $date and Twilio is working properly."
            )
        );

        return new Response("Sent message [$message->sid] via Twilio.");
    }
}

Inside a console command:

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Twilio\Rest\Client as TwilioClient;

#[AsCommand(name: 'twilio:test:sms', description: 'Test the Twilio integration by sending a text message.')]
class TwilioTestCommand extends ContainerAwareCommand
{
    public function __construct(private TwilioClient $twilioClient)
    {}

    protected function execute(InputInterface $input, OutputInterface $output)
    {
         $date = date('r');

         $message = $this->twilioClient->messages->create(
             '+12125551234', // Text any number
             array(
                 'from' => '+14085551234', // From a Twilio number in your account
                 'body' => "Hi there, it's $date and Twilio is working properly."
             )
         );

        $output->writeln("Sent message [$message->sid] via Twilio.");
    }
}

Copyright / License

See LICENSE, (*9)

The Versions

28/11 2016

dev-master

9999999-dev https://github.com/mblackford/BlackfordTwilioBundle

Symfony 3 / PHP 7 wrapper for the official Twilio SDK v5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matthew Blackford

twilio

28/11 2016

v5.0.1

5.0.1.0 https://github.com/mblackford/BlackfordTwilioBundle

Symfony 3 / PHP 7 wrapper for the official Twilio SDK v5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matthew Blackford

twilio

28/11 2016

v5.0.0

5.0.0.0 https://github.com/mblackford/BlackfordTwilioBundle

Symfony 3 / PHP 7 wrapper for the official Twilio SDK v5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matthew Blackford

twilio

17/08 2016

1.0.2

1.0.2.0 https://github.com/fridolin-koch/VreshTwilioBundle

A simple Symfony 2, 3 bundle for the official sdk provided by Twilio.

  Sources   Download

MIT

The Requires

 

The Development Requires

twilio

14/06 2016

1.0.1

1.0.1.0 https://github.com/fridolin-koch/VreshTwilioBundle

A simple Symfony 2, 3 bundle for the official sdk provided by Twilio.

  Sources   Download

MIT

The Requires

 

The Development Requires

twilio

06/02 2016

v1.0.0

1.0.0.0 https://github.com/fridolin-koch/VreshTwilioBundle

A simple Symfony 2, 3 bundle for the official sdk provided by Twilio.

  Sources   Download

MIT

The Requires

 

The Development Requires

twilio

02/11 2015

0.5.0

0.5.0.0 https://github.com/fridolin-koch/VreshTwilioBundle

A simple Symfony2 bundle for the official sdk provided by Twilio.

  Sources   Download

MIT

The Requires

 

The Development Requires

twilio

16/07 2014

0.4.3

0.4.3.0 https://github.com/fridolin-koch/VreshTwilioBundle

A simple Symfony2 bundle for the official sdk provided by Twilio.

  Sources   Download

MIT

The Requires

 

The Development Requires

twilio

25/04 2014

v0.4.2

0.4.2.0 https://github.com/fridolin-koch/VreshTwilioBundle

A simple Symfony2 bundle for the official sdk provided by Twilio.

  Sources   Download

MIT

The Requires

 

twilio

21/04 2013

v0.4.1

0.4.1.0 https://github.com/fridolin-koch/VreshTwilioBundle

A simple Symfony2 bundle for the official sdk provided by Twilio.

  Sources   Download

MIT

The Requires

 

twilio

20/04 2013

v0.4

0.4.0.0 https://github.com/fridolin-koch/VreshTwilioBundle

A simple Symfony2 bundle for the official sdk provided by Twilio.

  Sources   Download

MIT

The Requires

 

twilio

04/04 2013

v0.3

0.3.0.0 https://github.com/fridolin-koch/VreshTwilioBundle

A simple Symfony2 bundle for the official sdk provided by Twilio.

  Sources   Download

MIT

The Requires

 

twilio

20/10 2012

v0.2

0.2.0.0 https://github.com/fridolin-koch/VreshTwilioBundle

Symfony TwilioBundle

  Sources   Download

MIT

The Requires

 

twilio