- How do I install and configure the Laravel SMS Client package for Asanak API?
- Run `composer require asanak/laravel-sms-client`, then publish the config with `php artisan vendor:publish --tag=asanak-config`. Add your Asanak credentials to `.env` under `ASANAK_SMS_USERNAME`, `ASANAK_SMS_PASSWORD`, and `ASANAK_SMS_BASE_URL`. The package auto-registers the provider and facade, so no manual bootstrapping is needed.
- Does this package support sending bulk SMS or peer-to-peer (P2P) messages?
- Yes, the package supports both bulk and P2P messages. Use the `p2p()` method to send multiple messages with different sources, destinations, and texts in a single API call. This is useful for campaigns or multi-recipient notifications.
- Can I send OTPs or templated SMS messages using this package?
- Absolutely. Use the `template()` method to send SMS with predefined templates. Pass the `template_id` and an array of parameters (e.g., `['code' => '12345']`) to dynamically populate the template. This is ideal for authentication flows or transactional alerts.
- How do I check the status of sent SMS messages?
- Use the `msgStatus()` method to fetch the delivery status of messages by passing an array of message IDs. This is useful for tracking failed deliveries or confirming successful sends in critical workflows like OTP verification.
- Is this package compatible with Laravel 10 or 11?
- The package is designed for Laravel 10 and supports Laravel 11. To avoid compatibility issues, pin your Laravel version in `composer.json` (e.g., `^10.0` or `^11.0`). Always check the package’s GitHub for updates if you’re using a newer Laravel release.
- Can I send SMS messages asynchronously using queues?
- Yes, the package includes a `SendSmsJob` class for queueing SMS sends. Dispatch the job with `SendSmsJob::dispatch($data)` in your controller. Ensure your queue worker (e.g., Laravel Horizon or Redis) is running to process jobs asynchronously.
- How do I enable logging for SMS activities?
- Set `ASANAK_SMS_LOG=true` in your `.env` file. Logs will be stored in the `storage/logs/sms.log` file by default. This helps with debugging and auditing SMS-related operations in your application.
- What if I need to use a different SMS provider (e.g., Kavenegar, Clickatell) instead of Asanak?
- The package is built to be provider-agnostic. You can extend the base `Provider` class or implement the `ProviderInterface` to create a custom adapter for other SMS gateways. Check the package’s GitHub for examples or documentation on extending functionality.
- How do I handle failed SMS sends or retries in production?
- Failed jobs are automatically logged in Laravel’s `failed_jobs` table. Use Laravel Horizon or Supervisor to monitor and retry failed jobs. For critical messages, implement retry logic with exponential backoff in the `SendSmsJob` class.
- Are there any alternatives to this package for Laravel SMS integration?
- Yes, alternatives include `laravel-notification-channels/sms` (for Laravel Notifications) or provider-specific packages like `kavenegar/laravel-notification-channel-kavenegar`. However, this package is tailored for Asanak’s API, offering direct methods for P2P, templates, and status checks without extra abstraction layers.