All Projects → fre5h → SinchBundle

fre5h / SinchBundle

Licence: MIT license
📦 Provides integration with Sinch.com SMS API.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to SinchBundle

hashed-asset-bundle
Apply an asset version based on a hash of the asset for symfony/asset
Stars: ✭ 24 (+100%)
Mutual labels:  bundle, symfony-bundle
breadcrumb-bundle
Symfony bundle for easy breadcrumbs management
Stars: ✭ 26 (+116.67%)
Mutual labels:  bundle, symfony-bundle
connect-bundle
No description or website provided.
Stars: ✭ 35 (+191.67%)
Mutual labels:  bundle, symfony-bundle
DynamicParametersBundle
[UNMAINTAINED] Runtime retrieval of parameters from environment variables for Symfony
Stars: ✭ 42 (+250%)
Mutual labels:  bundle, symfony-bundle
OpcacheBundle
Displays the PHP OPcache status in the Symfony profiler toolbar.
Stars: ✭ 21 (+75%)
Mutual labels:  bundle, symfony-bundle
LiipImagineSerializationBundle
Provides integration between LiipImagineBundle and JMSSerializerBundle
Stars: ✭ 24 (+100%)
Mutual labels:  bundle, symfony-bundle
LiipSoapRecorderBundle
[DEPRECATED] Recorder/Player for SOAP communications
Stars: ✭ 12 (+0%)
Mutual labels:  bundle, symfony-bundle
SonataDashboardBundle
[Abandoned] Provides a Dashboard management through container and block services
Stars: ✭ 17 (+41.67%)
Mutual labels:  bundle, symfony-bundle
socketio
No description or website provided.
Stars: ✭ 23 (+91.67%)
Mutual labels:  bundle, symfony-bundle
BeelabTagBundle
🏷 A simple implementation of tags for Symfony and Doctrine ORM
Stars: ✭ 45 (+275%)
Mutual labels:  bundle, symfony-bundle
FkrCssURLRewriteBundle
A small assetic filter for symfony to fix all url paths at css documents to correct urls
Stars: ✭ 33 (+175%)
Mutual labels:  bundle, symfony-bundle
SonataFormatterBundle
Symfony SonataFormatterBundle
Stars: ✭ 78 (+550%)
Mutual labels:  bundle, symfony-bundle
SonataDoctrineMongoDBAdminBundle
Symfony Sonata / Integrate Doctrine MongoDB ODM into the SonataAdminBundle
Stars: ✭ 64 (+433.33%)
Mutual labels:  bundle, symfony-bundle
jsonrpc-bundle
JSON-RPC server for Symfony: exposes services registered in the service container as JSON-RPC-webservices
Stars: ✭ 31 (+158.33%)
Mutual labels:  bundle, symfony-bundle
stampie-bundle
stampie.github.io/
Stars: ✭ 26 (+116.67%)
Mutual labels:  bundle, symfony-bundle
NucleosDompdfBundle
📜 This bundle provides a wrapper for using dompdf inside symfony.
Stars: ✭ 29 (+141.67%)
Mutual labels:  bundle, symfony-bundle
LiipSearchBundle
[DEPRECATED] Google XML API for searching is discontinued
Stars: ✭ 35 (+191.67%)
Mutual labels:  bundle, symfony-bundle
SlackBundle
SlackBundle for Symfony2 with Guzzle-Integration
Stars: ✭ 39 (+225%)
Mutual labels:  bundle, symfony-bundle
awsBundle
Symfony AWS Bundle (supports Symfony 2, 3 and 4)
Stars: ✭ 18 (+50%)
Mutual labels:  bundle, symfony-bundle
wordpress-bundle
Use Wordpress and Symfony together using a Symfony bundle
Stars: ✭ 30 (+150%)
Mutual labels:  bundle, symfony-bundle

SinchBundle

📦 Provides integration with Sinch.com SMS API.

Currently in development process! Things can be changed at any moment!

Sinch Logo

Scrutinizer Quality Score Build Status CodeCov License Latest Stable Version Total Downloads StyleCI Gitter

SensioLabsInsight knpbundles.com

Requirements

  • PHP 7.1 and later
  • Symfony 4.0 and later

Installation

Create application for Sinch

Sing up in Sinch.com and create a new app.

Add dependency via Composer

composer req fresh/sinch-bundle='dev-master'

Add key and secret to parameters.yml

Add the following lines to your parameters.yml.dist file:

parameters:
    sinch.key: EnterKeyForYourSinchApp
    sinch.secret: EnterSecretForYourSinchApp

During the composer update you have to enter your own key and secret for your Sinch application, which you can find in your Sinch dashboard.

Update config.yml

Add the following lines to config.yml file:

fresh_sinch:
    key: "%sinch.key%"
    secret: "%sinch.secret%"

Usage

Example of sending SMS

use Fresh\SinchBundle\Service\Sinch;

class Foo {
    public function bar(Sinch $sinch) {
        // Set the outbound number where you want to send the SMS
        $messageId = $sinch->sendSMS('+13155555552', 'Your message');
        
        // If success then the ID of sent message is returned (it is an integer value)
        echo $messageId;
    }
}

Example of checking SMS status

use Fresh\SinchBundle\Service\Sinch;

class Foo {
    public function bar(Sinch $sinch) {
        $messageId = 123456789; // The ID of Sinch message you get after successful SMS sending
        
        // Status is a string with one of these values: pending, successful, faulted, unknown
        $status = $sinch->getStatusOfSMS($messageId);
        
        // Other helper methods, return true of false
        $sinch->smsIsSentSuccessfully($messageId);
        $sinch->smsIsPending($messageId);
        $sinch->smsIsFaulted($messageId);
        $sinch->smsInUnknownStatus($messageId);
    }
}

Catching and processing Sinch exceptions

use Fresh\SinchBundle\Exception\PaymentRequired\SinchPaymentRequiredException;
use Fresh\SinchBundle\Service\Sinch;

class Foo {
    public function bar(Sinch $sinch) {
        try {
            $messageId = $sinch->sendSMS($phoneNumber, 'Your message');
            // Some logic related to SMS processing...
        } catch (SinchPaymentRequiredException $e) {
            $logger->error('SMS was not sent. Looks like your Sinch account run out of money.');
            // Here you can, for example, send urgent emails to admin users
            // to notify that your Sinch account run out of money
        }
    }
}

Contributing

See CONTRIBUTING file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].