🚫 This project is no longer maintained.
Provider neutral SMS library for PHP 5.5+
Read the documentation for the last release here.
composer require litgroup/sms=0.6.*
use LitGroup\Sms\Message;
use LitGroup\Sms\MessageService;
use LitGroup\Sms\Exception\SmsException;
// Some implementation of `LitGroup\Sms\Gateway\GatewayInterface`
$gateway = new SomeGateway();
// Create Short Message Service
$messageService = new MessageService($gateway);
// Create and send some message.
try {
$messageService->sendMessage(
'Hello, customer!',
['+79991234567'],
'AcmeCompany'
);
} catch (SmsException $e) {
// ...
}
It's possible to use cascade of gateways of several providers to improve
fault-tolerance. Use LitGroup\Sms\Gateway\CascadeGateway
.
$cascadeGateway = new CascadeGateway([
new AGateway(),
new BGateway(),
]);
$messageService = new MessageService($cascadeGateway);
- Constructor of
MessageService
receivesPsr\Log\LoggerInterface
. - If you use
CascadeGateway
then inject a logger into the instance ofCascadeGateway
too.Warnings
will be logged if some of gateways are inoperative.