2017 © Pedro Peláez
 

project yii2-sms-sender

Yii2 SMS sender

image

matperez/yii2-sms-sender

Yii2 SMS sender

  • Saturday, February 4, 2017
  • by matperez
  • Repository
  • 1 Watchers
  • 0 Stars
  • 180 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 2 % Grown

The README.md

yii2-sms-sender

Build Status Coverage Status, (*1)

Yii2 SMS Sender, (*2)

Setup

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist matperez/yii2-sms-sender

or add, (*5)

"matperez/yii2-sms-sender": "*"

to the require section of your composer.json file., (*6)

Dev environment

'components' = [
  'sms' => [
    'viewPath' => '@app/sms',
    'class' => \matperez\yii2smssender\components\Sender::class,
    'transportConfig' => [
      'class' => \matperez\yii2smssender\transports\FileTransport::class, 
    ],
  ],
],

Production environment

Using https://integrationapi.net, (*7)

'components' = [
  'sms' => [
    'viewPath' => '@app/sms',
    'class' => \matperez\yii2smssender\components\Sender::class,
    'transportConfig' => [
      'class' => \matperez\yii2smssender\transports\IntegrationApiTransport::class,
      'login' => 'login',
      'password' => 'password',
    ],
  ],
],

Place this somewhere in a bootstrap file, (*8)

\Yii::$container->set(\GuzzleHttp\ClientInterface::class, function() {
  return new \GuzzleHttp\Client();
});

Usage

Composing a message

The message can be composed from a template. The template name could be relative to viewPath or it could be a full path to a the view. Yii aliases are acceptable., (*9)

$message = Yii::$app->sms->compose('template_name', $params);
$message = Yii::$app->sms->compose('@app/sms/template_name', $params);

It is also possible to compose an empty message when no view name provided, (*10)

$message = Yii::$app->sms->compose();

Middleware

The message can be preprocessed prior to sending. For example log or modify its content. Middleware should be set as an array of callable., (*11)

'components' = [
  'sms' => [
      'class' => \matperez\yii2smssender\components\Sender::class,
      'middleware' => [
          function(\matperez\yii2smssender\interfaces\IMessage $message) {
              $message->setMessage('new message content');
          }
      ]
  ],
],

Sending a message

$message = Yii::$app->sms->compose('some-view', $params);
$message->setTo('1234345456');
$message->setFrom('sender');
$message->send();

Balance checking

if (Yii::$app->sms->canFetchBalance()) {
  $balance = Yii::$app->sms->getBalance();
}

The Versions

04/02 2017

dev-master

9999999-dev

Yii2 SMS sender

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Golovin

yii2 sms

04/02 2017

1.3.0

1.3.0.0

Yii2 SMS sender

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Golovin

yii2 sms

03/02 2017

1.2.4

1.2.4.0

Yii2 SMS sender

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Golovin

yii2 sms

03/02 2017

1.2.3

1.2.3.0

Yii2 SMS sender

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Golovin

yii2 sms

02/02 2017

1.2.2

1.2.2.0

Yii2 SMS sender

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Golovin

yii2 sms

02/02 2017

1.2.1

1.2.1.0

Yii2 SMS sender

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Golovin

yii2 sms

02/02 2017

1.2.0

1.2.0.0

Yii2 SMS sender

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Golovin

02/02 2017

1.1.3

1.1.3.0

Yii2 SMS sender

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Golovin

02/02 2017

1.1.2

1.1.2.0

Yii2 SMS sender

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Golovin

25/09 2016

1.1.1

1.1.1.0

Yii2 SMS sender

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Golovin

25/09 2016

1.1.0

1.1.0.0

Yii2 SMS sender

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Golovin

19/09 2016

1.0.0

1.0.0.0

Yii2 SMS sender

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Golovin