- Can I use symfony/light-sms-notifier directly in Laravel without extra setup?
- No, this package is Symfony-first and requires manual integration. You’ll need to bind Symfony’s Notifier services to Laravel’s container via a ServiceProvider and create custom wrappers for Laravel’s Notification facade. The DSN-based config (e.g., `lightsms://LOGIN:TOKEN@default?from=PHONE`) works, but Laravel’s `.env` conventions won’t apply automatically.
- What Laravel versions support symfony/light-sms-notifier?
- Laravel 10+ is recommended due to Symfony 8.x dependencies (PHP 8.4+). Check for version conflicts with Laravel’s bundled Symfony components (e.g., `symfony/http-client`). If using Laravel 9 or older, you may need to pin Symfony versions manually in `composer.json` or risk compatibility issues.
- How do I configure LightSMS in Laravel’s .env file?
- Add `LIGHTSMS_DSN=lightsms://LOGIN:TOKEN@default?from=+1234567890` to your `.env`. Replace `LOGIN` and `TOKEN` with your LightSMS credentials (from [LightSMS API settings](https://www.lightsms.com/external/client/api/)) and `PHONE` with your sender’s number in E.164 format (e.g., `+1234567890`).
- Is there a simpler alternative for Laravel SMS notifications?
- Yes, consider `laravel-notification-channels/lightsms` or `spatie/laravel-sms-notifications` for tighter Laravel integration. These packages often include built-in facades, queue support, and `.env` conventions, reducing manual setup. Symfony’s bridge is better for Symfony-heavy projects or if you’re already using Symfony Notifier.
- How do I send SMS notifications in Laravel using this package?
- Create a custom `SmsChannel` class wrapping Symfony’s `NotifierInterface`, then use Laravel’s `Notification` facade. Example: `public function via($notifier) { return [new SmsChannel($notifier)]; }`. Ensure the Symfony `SmsNotifier` is bound in a Laravel ServiceProvider before sending notifications.
- Will this package work with Laravel Queues (Horizon) for delayed SMS?
- No, Symfony’s Messenger (used by this package) doesn’t integrate natively with Laravel Queues. You’ll need to manually dispatch messages or use a custom queue adapter. For production, consider LightSMS’s built-in queueing or a dedicated Laravel SMS package with queue support.
- Are there any known issues with testing this package in Laravel?
- Yes, mocking Symfony’s `NotifierInterface` in PHPUnit requires extra setup. Use Laravel’s `Mockery` or `createMock()` to stub the `Notifier` and `LightSmsTransport`. Test your `SmsChannel` wrapper separately to isolate Laravel-specific logic. Symfony’s event system also differs from Laravel’s, so test event-driven workflows carefully.
- Can I switch SMS providers later without rewriting code?
- Switching providers is possible but not seamless. The DSN format (`lightsms://...`) is provider-specific, so you’d need to update the DSN and potentially refactor transport logic. For abstraction, design a custom `SmsTransport` interface and implement adapters for each provider (e.g., LightSMS, Twilio).
- Does this package support MMS or advanced SMS features like scheduling?
- No, this package is basic and focuses on sending SMS via LightSMS’s API. For MMS, scheduling, or analytics, use LightSMS’s [web API](https://www.lightsms.com/external/client/api/) directly or a provider-specific Laravel package. Symfony Notifier’s bridge doesn’t expose these features.
- How do I handle errors or retries for failed SMS deliveries?
- Symfony Notifier includes basic retry logic for transient failures, but you’ll need to implement custom error handling in Laravel. Log exceptions using Laravel’s `Log` facade and consider wrapping the `LightSmsTransport` in a retry decorator (e.g., Symfony’s `RetryStrategy`). LightSMS’s API also provides delivery receipts you can poll separately.