myowncode/symfony-turbosms

Turbosms service client for Symfony applications

v1.0.4 2019-01-02 10:15 UTC

This package is auto-updated.

Last update: 2024-04-29 04:07:06 UTC


README

This bundle helps you to integrate with http://turbosms.ua service in Symfony4 project.

Installation

Composer

You can use Composer for the automated process:

$ composer require myowncode/symfony-turbosms

or manually add link to bundle into your composer.json and run $ composer update:

{
    "require" : {
        "myowncode/symfony-turbosms": "~1.0"
    }
}

Composer will install bundle to vendor/myowncode/symfony-turbosms directory.

Adding bundle to your application kernel

<?php

// app/config/bundles.php

return [
    // some other bundles
    Myowncode\TurboSmsBundle\MyowncodeTurbosmsBundle::class => ['all' => true],
];

Configuration

# app/config/packages/myowncode_turbosms.yaml

myowncode_turbosms:
    login: your_login
    password: your_password
    sender: your_sender_name
    # or false
    debug: true
    # or false
    save_to_db: true
    # default wsdl source (could change. Look at provider settings)
    wsdl: http://turbosms.in.ua/api/wsdl.html

Now you need create the tables in your database:

$ php bin/console doctrine:schema:update --dump-sql

or just perform migrations diff:

$ php bin/console doctrine:migrations:diff

This will show SQL queries for creating of tables in the database (or create new migrations). You may manually run these queries.

Note. You may also execute php bin/console doctrine:schema:update --force command, and Doctrine will create needed tables for you. But I strongly recommend you to execute --dump-sql first and check SQL, which Doctrine will execute.

Use in controller

<?php 

namespace App\YourBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class MyCustomController extends Controller
{
    /**
     * @Route("/")
     * @Template()
     */
    public function indexAction(): void
    {
        // some code goes here
        $this->get('myowncode_turbosms')->send("test", "+XXXXXXXXXXXX");
        // some code goes here
    }
}

TODO

  • Add tests
  • Translate message
  • Save log to file
  • Integrate with EasyAdmin

License

symfony-turbosms is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.