PHP code example of jakharbek / yii2-sms

1. Go to this page and download the library: Download jakharbek/yii2-sms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jakharbek / yii2-sms example snippets


use jakharbek\sms\providers\playmobile\PlaymobileConnectionDTO;
use jakharbek\sms\providers\playmobile\PlaymobileDriver;

...

$dto = new PlaymobileConnectionDTO();
$dto->username = getenv("PLAYMOBILE_USERNAME");
$dto->password = getenv("PLAYMOBILE_PASSWORD");
$dto->originator = getenv("PLAYMOBILE_ORIGINATOR");

$playmobile = new PlaymobileDriver($dto);
$playmobile->sendSms($phone,$sms);

$container->setSingleton(SmsSenderInterface::class, function () {
           $dto = new PlaymobileConnectionDTO();
           $dto->originator = getenv("PLAYMOBILE_ORIGINATOR");
           $dto->username = getenv("PLAYMOBILE_USERNAME");
           $dto->password = getenv("PLAYMOBILE_PASSWORD");
           return new PlaymobileDriver($dto);
        });

use jakharbek\sms\interfaces\SmsSenderInterface::class

/**
* @var $smsSender SmsSenderInterface
*/

$smsSender = Yii::$container->get(SmsSenderInterface::class);
$smsSender->sendSms($phone,$sms);

yii migrate --migrationPath=@vendor/jakharbek/yii2-sms/migrations
 
\jakharbek\sms\controllers\SmsController

[
//конфигурационный файл приложение
...

'controllerMap' => [
        'sms' => \jakharbek\sms\controllers\SmsController::class,
    ],
    
...
]


playmobile

jakharbek\sms\interfaces\SmsSenderInterface::class

php composer.phar