- How do I integrate this package into a Laravel app that already uses Symfony Notifier?
- If your Laravel app uses Symfony Notifier (e.g., via spatie/laravel-notifier), add the package via Composer (`symfony/smsapi-notifier`), configure the DSN in your `.env` (e.g., `SMSAPI_DSN=smsapi://TOKEN@default?from=SENDER`), and replace your SMS logic with Symfony’s `SmsMessage`. No additional Laravel-specific setup is needed.
- What Laravel versions does this package support?
- This package is Symfony-focused, not Laravel-native, but works with Laravel 8+ or 9+ if you’re using Symfony components (e.g., via spatie/laravel-symfony-messenger). For older Laravel versions, ensure compatibility with Symfony Notifier ^6.0, which it depends on.
- Can I use this package without Symfony Notifier in a Laravel app?
- No, this package requires Symfony Notifier as a dependency. If you’re not using Symfony Notifier, you’ll need to either adopt it (via spatie/laravel-notifier) or build a lightweight SMSAPI client using Guzzle or Symfony’s HTTP client, then integrate it with Laravel’s queue system.
- How do I configure the sender name and fast delivery in the DSN?
- Use the DSN format in your `.env`: `SMSAPI_DSN=smsapi://TOKEN@default?from=YOUR_SENDER&fast=1`. Replace `YOUR_SENDER` with your sender ID and set `fast=1` for priority delivery. Omit `from` to use SMSAPI’s default ‘eco’ sender. Test mode is enabled with `test=1`.
- What’s the best way to handle errors or failed SMS deliveries?
- Symfony Notifier provides built-in retry logic for transient failures. For production, pair it with Laravel’s queue system (e.g., Horizon) and implement dead-letter queues for persistent failures. Use Laravel’s logging or monitoring (e.g., Sentry) to track SMS delivery statuses.
- Does this package support bulk SMS or scheduled messages?
- This package sends individual SMS messages via the SMSAPI API. For bulk or scheduled messages, use SMSAPI’s native bulk API (documented separately) and integrate it into a Laravel job or queue worker. The bridge doesn’t natively support these features.
- How do I test SMS sending without actually sending messages?
- Enable test mode in the DSN by adding `test=1` (e.g., `SMSAPI_DSN=smsapi://TOKEN@default?test=1`). This validates your message format without sending it. For unit tests, mock the Symfony Notifier transport or use SMSAPI’s sandbox environment if available.
- Are there alternatives to this package for Laravel SMS notifications?
- Yes. For Laravel-native solutions, consider `spatie/laravel-notification-channels-smsapi` (if available) or `laravel-notification-channels/sms`. For Symfony-based apps, this bridge is the most integrated option. If you need flexibility, build a custom client with Guzzle or use SMSAPI’s PHP SDK directly.
- How do I log SMS delivery statuses or failures in Laravel?
- Extend the Symfony Notifier transport or wrap the SMSAPI client in a Laravel service. Log responses using Laravel’s logging facade (e.g., `Log::info('SMS sent to ' . $to)`) or integrate with a monitoring tool like Sentry. For failures, publish events to a queue for later review.
- What’s the performance impact of using this package in production?
- The package adds minimal overhead if configured correctly. For high-volume apps, batch messages using Laravel queues or SMSAPI’s bulk API. Monitor latency by logging response times and consider caching the SMSAPI client instance to avoid reconnecting for each message.