- How do I install and configure the Ersalak Laravel SMS package?
- Run `composer require ersalak/ersalak-laravel-sms` to install. Publish the config with `php artisan vendor:publish --tag=ersalak-config`, then set your Ersalak credentials in `.env` under `ERSALAK_SMS_USERNAME`, `ERSALAK_SMS_PASSWORD`, and `ERSALAK_SMS_BASE_URL`. No manual provider/facade registration is needed.
- Which Laravel versions does this package support?
- The package is designed for Laravel 8+ and leverages modern Laravel features like facades and environment variables. Check the package’s Composer requirements for exact version constraints.
- Can I send bulk SMS messages (P2P) with this package?
- Yes, the package supports Peer-to-Peer (P2P) messaging. Use the `p2p()` facade method with arrays for `source`, `destination`, and `message` parameters to send multiple messages in one call.
- How do I handle OTP or template-based SMS messages?
- Use the `template()` facade method with a `template_id` and an array of parameters. For example, pass `['code' => 12345]` for an OTP template. The package handles the API call and returns message IDs for tracking.
- Does this package support checking SMS delivery status?
- Yes, the package includes a `msgStatus()` method to retrieve the status of sent messages. You can use the returned `message_id` from the initial send to fetch the status report later.
- How do I log SMS failures or errors in production?
- Enable logging by setting `ERSALAK_SMS_LOG=true` in your `.env`. The package will log errors to Laravel’s default log channel. For advanced monitoring, integrate with tools like Sentry or Laravel Horizon.
- Can I mock the SMS service for testing?
- Yes, you can mock the facade in tests using Laravel’s mocking utilities. For example, use `$this->mock(ErsalakSms::class)->shouldReceive('sendSms')->andReturn(['message_id' => '123'])` to simulate successful sends.
- What happens if Ersalak’s API rate limits me?
- The package does not include built-in rate limiting. For high-volume projects, defer SMS sends to Laravel’s queue system with delays or implement exponential backoff in your application logic.
- Is it possible to switch SMS providers later without rewriting code?
- The package is tightly coupled to Ersalak’s API, so switching providers may require refactoring. To mitigate this, abstract the facade behind an interface (e.g., `SmsServiceContract`) and use dependency injection for easier provider swaps.
- How do I handle multi-tenancy with separate Ersalak credentials?
- For multi-tenancy, dynamically override the `.env` values or use Laravel’s context binding to inject tenant-specific configurations. Store credentials securely in a database or encrypted storage and load them per tenant.