- Can I use this package directly in Laravel without Symfony dependencies?
- Yes, but you’ll need to wrap the Symfony Notifier components in a Laravel service. Replace Symfony’s HttpClient with Laravel’s Http facade or Guzzle, and adapt the SmsMessage class to fit Laravel’s job system. The core AllMySMS API functionality remains usable.
- What Laravel versions does this package support?
- The package itself is Symfony-centric, but it works with Laravel 9+ if you abstract the Symfony dependencies (e.g., HttpClient, Messenger) behind Laravel’s equivalents. Ensure your Laravel app uses PHP 8.1+ for Symfony 6+ compatibility, or PHP 8.4+ for Symfony 8+.
- How do I configure AllMySMS credentials in Laravel?
- Add your AllMySMS credentials to your `.env` file using the DSN format: `ALLMYSMS_DSN=allmysms://LOGIN:APIKEY@default?from=SENDER_ID`. Then bind the Symfony client to a Laravel service provider or facade for easy access in your app.
- Does this package support async SMS sending with Laravel queues?
- Yes, you can dispatch SMS sends as Laravel jobs (e.g., `SendSmsJob`) and process them asynchronously. Use Laravel’s queue system to handle retries and failures, or leverage AllMySMS’s webhooks for delivery status updates if needed.
- Can I customize SMS options like scheduling or simulation in Laravel?
- Absolutely. Use the `AllMySmsOptions` class to configure advanced features like scheduling (`date`), simulation (`simulate`), campaign names (`campaignName`), or unique identifiers. Attach these options to your `SmsMessage` before sending.
- What happens if an SMS fails to send? How do I handle retries?
- Failed SMS sends can be caught using Laravel’s queue failure system or by listening to Symfony’s `SentMessage` events. Implement exponential backoff logic in your job handler or use Laravel’s `retryAfter` method to control retry intervals.
- Are there alternatives to this package for Laravel?
- Yes. For AllMySMS specifically, you could use Guzzle to call the API directly or build a custom Laravel service. For other providers, consider `laravel-notification-channels/sms` (Twilio, Nexmo) or `spatie/laravel-sms-notifications` for broader compatibility.
- How do I test SMS sends without actually sending messages?
- Use AllMySMS’s simulation mode (`simulate(1)` in `AllMySmsOptions`) to test sends without charging. Mock the AllMySMS API responses in PHPUnit using Laravel’s HTTP testing tools or a service container mock.
- Does this package support tracking SMS delivery statuses?
- The package itself doesn’t include built-in tracking, but you can log delivery statuses by listening to Symfony’s `SentMessage` events and storing results in a Laravel database table. Alternatively, use AllMySMS’s API to poll statuses periodically.
- What’s the best way to integrate this with Laravel’s event system?
- Extend the Symfony `SentMessage` event to trigger Laravel events (e.g., `SmsSent`, `SmsFailed`). In your service provider, bind the Symfony notifier to a Laravel event dispatcher, then emit custom events when SMS sends succeed or fail.