sol-parts / symfony-smsfly-notifier
Symfony SMS-fly Notifier Bridge
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-notifier-bridge
pkg:composer/sol-parts/symfony-smsfly-notifier
Requires
- php: >=8.2
- ext-mbstring: *
- symfony/http-client: ^6.4|^7.0
- symfony/notifier: ^7.3
README
Provides SMS-fly integration for Symfony Notifier. SymfonySmsFlyNotifier allows you to send SMS and/or Viber messages
Installation
composer require sol-parts/symfony-smsfly-notifier
Example use without Symfony Full-Stack Framework
use Symfony\Component\Notifier\Message\SmsMessage; use SolParts\SymfonySmsFlyNotifier\SmsFlyTransport; use Psr\Log\LoggerInterface; /** @var LoggerInterface $logger */ $logger = /*...*/; try { $transport = new SmsFlyTransport('authKey', 'InfoCenter'); $sms = new SmsMessage('+380771234567', 'My sms message'); $sentMessage = $transport->send($sms); }catch (\Throwable $e) { $logger->critical($e->getMessage()); } dump($sentMessage->getMessageId()); // "FAPI00134035C3000004" dump($sentMessage->getInfo()); // [ // "success" => 1 // "date" => "2025-09-18 14:14:01 +0300" // "data" => array:2 [ // "messageID" => "FAPI00134035C3000004" // "sms" => array:3 [ // "status" => "ACCEPTD" // "date" => "2025-09-18 14:14:01 +0300" // "cost" => "0.979" // ] // ] // ]
Example if you are using Symfony Full-Stack Framework
# config/packages/notifier.yaml
SMSFLY_DSN=smsfly://AUTHKEY@default?from=InfoCenter
where:
AUTHKEYis your SMS-fly auth keyFROMis your sender name, should be alpha-numeral
use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\TexterInterface; /** @var TexterInterface $texter */ $texter = /*...*/; $sms = new SmsMessage('+380771234567', 'My sms message'); $texter->send($sms);
Adding custom Options to a Message
With a SMS-Fly Message, you can use the SmsFlyOptions class to add
message options.
use SolParts\SymfonySmsFlyNotifier\SmsFlyOptions; use Symfony\Component\Notifier\Message\SmsMessage; $options = (new SmsFlyOptions()) // Message sending channels. // Available values are viber, sms. If you specify multiple channels, the message is sent to the channels in order of priority. // The message is sent to the next channel if delivery to the previous one was not successful. // If not specified, ['sms'] will be used. ->channels(['viber', 'sms']) ->viber_source('Promo') // The Viber sender name, if not specified, will be the same as for SMS. ->viber_text('🎁 A special gift from Example Corp is here') // Optional field, Viber message text up to 1000 characters long. If not specified, the SMS message text will be used. ->viber_button_caption('Go to site') // Optional field ->viber_button_url('https://example.com/') // Optional field ->viber_image('https://example.com/image.jpg') // Optional field ->ttl(1440) ; /** @var SmsMessage $sms */ $sms = /*...*/; $sms->options($options);