fourlabs/plivo-bundle

Plivo Bundle for Symfony - Send and receive text messages

1.2.1 2018-07-10 14:54 UTC

This package is auto-updated.

Last update: 2024-12-22 07:58:46 UTC


README

StyleCI Total Downloads License

Installation

Install with composer

    $ composer require fourlabs/plivo-bundle eightpoints/guzzle-bundle

Add these bundles to app/AppKernel.php

<?php
    //...
    $bundles = [
        // ...
        // FLPlivoBundle depends on GuzzleBundle and MisdPhoneNumberBundle
        // Add them if they're not already present in your $bundles
        new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle(), 
        new Misd\PhoneNumberBundle\MisdPhoneNumberBundle(), 
        new FL\PlivoBundle\FLPlivoBundle(),    
    ];
            

Sample Configuration

app/config/config.yml

# Guzzle Configuration
eight_points_guzzle:
    clients:
        plivo: # configure plivo client
            base_url: 'https://api.plivo.com/v1/Account/%plivo_auth_id%/'
            headers:
                Accept: "application/json"
            options:
                auth:
                    - %plivo_auth_id% # user
                    - %plivo_auth_token% # password
                timeout: 30

# Plivo Configuration
fl_plivo:
  sms_incoming_class: AppBundle\Entity\SmsIncoming
  sms_outgoing_class: AppBundle\Entity\SmsOutgoing
  development_mode: true # if set to true, sms will not be sent - defaults to false

app/config/services.yml

guzzle.client.plivo:
  alias: eight_points_guzzle.client.plivo

app/config/routing.yml

fl_plivo:
    resource: "@FLPlivoBundle/Resources/config/routing.yml"
    prefix:   /

Suggested Implementation

  • Create an entity for your ORM/ODM (e.g. Doctrine) that extends \Plivo\Model\SmsIncoming
  • Create an entity that extends \Plivo\Model\SmsOutgoing
  • If you are using Doctrine, you can use the corresponding event listeners, by importing them.
# app/config/config.yml
imports:
    - { resource: "@FLPlivoBundle/Resources/config/event-listener/doctrine.yml"}
  • If you are using not using Doctrine, create your own event listeners and submit a pull request ;)
  • To receive SMS messages, follow the instructions from Plivo
  • Use the corresponding url for the route fl_plivo.post_message (If you imported the default routing file, without a prefix, this would be /api/v1.0/message)

License

PlivoBundle is licensed under the MIT license.