gijsrommers / smstools-notifier
SMSTools transport for Symfony Notifier
Package info
github.com/GijsRommers/smstools-notifier
Type:symfony-notifier-bridge
pkg:composer/gijsrommers/smstools-notifier
Requires
- php: ^8.1
- symfony/config: ^6.4 || ^7.0 || ^8.0
- symfony/dependency-injection: ^6.4 || ^7.0 || ^8.0
- symfony/event-dispatcher-contracts: ^3.5
- symfony/http-client-contracts: ^3.5
- symfony/http-kernel: ^6.4 || ^7.0 || ^8.0
- symfony/notifier: ^6.4 || ^7.0 || ^8.0
Requires (Dev)
- phpunit/phpunit: ^10.5 || ^11.5 || ^12.0
- symfony/http-client: ^6.4 || ^7.0 || ^8.0
- symfony/webhook: ^6.4 || ^7.0 || ^8.0
Suggests
- symfony/webhook: Required to consume and verify SMSTools delivery webhooks.
README
An unofficial SMSTools transport for Symfony Notifier.
Installation
composer require gijsrommers/smstools-notifier
Configure the transport:
SMS_TOOLS_DSN=smstools://CLIENT_ID:CLIENT_SECRET@default?from=MyApp
# config/packages/notifier.yaml framework: notifier: texter_transports: smstools: '%env(SMS_TOOLS_DSN)%'
Symfony Flex enables SmstoolsNotifierBundle and creates this configuration
automatically. Applications without Flex can enable the bundle manually in
config/bundles.php.
Send an SMS using Symfony's standard API:
use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\TexterInterface; $texter->send(new SmsMessage('32470123456', 'Hello from Symfony!'));
The from value in an individual SmsMessage overrides the sender configured in the DSN. URL-encode credentials containing reserved URI characters.
Delivery webhooks
Install Symfony Webhook if it is not already present:
composer require symfony/webhook
Register the parser and configure a webhook route with the signing secret shown by SMSTools:
# config/services.yaml services: GijsRommers\SmstoolsNotifier\Webhook\SmstoolsRequestParser: ~
# config/packages/webhook.yaml framework: webhook: routing: smstools: service: GijsRommers\SmstoolsNotifier\Webhook\SmstoolsRequestParser secret: '%env(SMS_TOOLS_WEBHOOK_SECRET)%'
Point the SMSTools webhook at /webhook/smstools. The parser validates the
X-Smstools-Timestamp and X-Smstools-Signature headers against the unmodified
request body and rejects signatures older than five minutes. Delivery reports
with terminal delivered/not-delivered codes are exposed as Symfony SmsEvent
instances. Intermediate reports and other authenticated SMSTools events remain
available as generic RemoteEvent instances.
Development
composer install
composer test
License
MIT. This package is community-maintained and is not an official SMSTools product.