symfony/smsapi-notifier
Symfony Notifier bridge for SMSAPI (smsapi.pl / smsapi.com). Send SMS using an OAuth token via DSN config, with options for sender name, fast delivery priority, and test mode.
spatie/laravel-notifier or spatie/laravel-symfony-messenger. This provides a clean abstraction for SMS notifications without tightly coupling to Symfony’s ecosystem.SMSAPI_DSN). This aligns well with Laravel’s .env and dependency injection systems.symfony/notifier:^6.0 (or ^7.0 for newer Laravel apps).spatie/laravel-notifier (if not already using Symfony Notifier).symfony/messenger for async processing (if Laravel queues are in use)..env):
SMSAPI_DSN=smsapi://API_TOKEN@api.smsapi.com?from=SenderName&fast=1
config/services.php or a custom provider.Http::post() calls) with Symfony’s SmsMessage:
use Symfony\Component\Notifier\Message\SmsMessage;
use Symfony\Component\Notifier\NotifierInterface;
$notifier = app(NotifierInterface::class);
$notifier->send(new SmsMessage('Recipient', 'Hello!'));
Illuminate\Events\Dispatcher for post-send hooks.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Symfony Version Mismatch | Medium | Pin symfony/notifier to a stable version (e.g., ^6.4) to avoid breaking changes. |
| SMSAPI API Instability | High | Implement retry logic (e.g., spatie/laravel-retryable) and circuit breakers. |
| Laravel-Symfony DI Conflicts | Low | Use spatie/laravel-symfony-messenger to resolve dependency conflicts. |
| Testing Complexity | Medium | Mock SMSAPI responses with Pest/Mockery or use SMSAPI’s sandbox mode. |
| Cost Overruns | Medium | Monitor SMS usage via SMSAPI’s dashboard and set budget alerts. |
Sentry).?test=1) meets QA requirements.spatie/laravel-notifier).spatie/laravel-notification-channels for multi-channel support.composer require symfony/notifier spatie/laravel-notifier symfony/smsapi-notifier
.env:
SMSAPI_DSN=smsapi://API_TOKEN@api.smsapi.com?from=SenderName
config/services.php:
'notifier' => [
'transports' => [
'smsapi' => env('SMSAPI_DSN'),
],
],
SmsapiService class:
use GuzzleHttp\Client;
class SmsapiService {
public function __construct(private Client $client) {}
public function send(string $to, string $message): bool {
$response = $this->client->post('https://api.smsapi.com/sms', [
'auth' => [env('SMSAPI_KEY'), ''],
'json' => ['to' => $to, 'text' => $message],
]);
return $response->getStatusCode() === 200;
}
}
$this->app->singleton(SmsapiService::class, fn() => new SmsapiService(new Client()));
SmsMessage (Symfony Notifier) or SmsapiService.// Using Symfony Notifier
$notifier->send(new SmsMessage('+123456789', 'Your OTP: 12345'));
// Using Custom Service
app(SmsapiService::class)->send('+123456789', 'Your OTP: 12345');
use Symfony\Component\Notifier\EventListener\SentMessageListenerInterface;
class SmsSentListener implements SentMessageListenerInterface {
public function onMessageSent(object $message): void {
// Log or dispatch Laravel events
}
}
^6.4 for stability; ^7.0 for newer features.symfony/notifier and symfony/smsapi-notifier for updates."scripts": {
"post-update-cmd": "php artisan config:clear"
}
.env and use Laravel Forge/Envoyer for deployments..env template:
SMSAPI_DSN=smsapi://${SMSAPI_TOKEN}@${SMSAPI_ENDPOINT}?from=${SMSAPI_SENDER}
$notifier->send(..., ['debug' => true]);
SMSAPI_DSN format.How can I help you explore Laravel packages today?