- How do I install and set up `kavenegar/laravel-notification` for Laravel 5.3/5.4?
- Run `composer require kavenegar/laravel-notification`, register `KavenegarServiceProvider` in `config/app.php`, and add your Kavenegar API key and sender number to `config/services.php` under the `kavenegar` array. Use environment variables (`KAVENEGAR_API_KEY`, `KAVENEGAR_SENDER`) for security.
- Does this package work with Laravel 6+ or newer versions?
- No, this package is designed for Laravel 5.3/5.4 only. Laravel 6+ introduced breaking changes to the Notification contract (e.g., `routeNotificationFor()` vs. `routeNotificationForSms()`), so you’d need to fork or replace it with a modern alternative like `laravel-notification-channels` for compatibility.
- How do I route SMS notifications to specific phone numbers in my app?
- Add a `routeNotificationForSms()` method to your notifiable model (e.g., `User`). Return the phone number field (e.g., `return $this->phone;`). The package will automatically use this number when sending SMS via the `KavenegarChannel`.
- Can I use this package for production SMS alerts (e.g., OTPs, critical notifications)?
- This package is unmaintained (last updated in 2017) and lacks features like retries, queue support, or error handling. For production use, consider alternatives with active maintenance, such as `laravel-notification-channels/kavenegar`, or evaluate Kavenegar’s official API directly for reliability guarantees.
- What if I need to switch SMS providers later? Will this package lock me in?
- Yes, this package is tightly coupled with Kavenegar’s API. Switching providers would require rewriting the notification logic. For flexibility, use a multi-channel package like `laravel-notification-channels`, which supports multiple SMS providers (e.g., Twilio, Nexmo) under one interface.
- How do I test SMS notifications locally without sending real texts?
- This package doesn’t include built-in mocking for testing. You can manually override the `KavenegarChannel` in tests to return fake responses or use Laravel’s `NotificationFake` to assert if notifications were dispatched. For SMS-specific testing, consider mocking the Kavenegar API client directly.
- Is there support for SMS templates or dynamic content in this package?
- No, this package only supports static messages via the `toSMS()` method. For dynamic templates or advanced SMS features (e.g., personalization, scheduling), you’d need to extend the package or use Kavenegar’s API directly with custom logic.
- Will this package work with Laravel queues for delayed SMS notifications?
- No, this package doesn’t support Laravel’s queue system. SMS notifications are sent synchronously. For queued SMS, you’d need to modify the package to implement `ShouldQueue` or use a modern alternative that supports async delivery.
- Are there any security risks using this unmaintained package in production?
- Yes, unmaintained packages may expose vulnerabilities (e.g., outdated dependencies, lack of security patches). Since Laravel 5.3/5.4 are deprecated, this package won’t receive updates for PHP 8.x or modern Laravel features. Assess the risk based on your SMS use case and consider a maintained alternative.
- How do I handle failed SMS deliveries or retries with this package?
- This package lacks built-in retry logic or failure handling. Failed SMS deliveries would require custom error handling (e.g., catching exceptions in `toSMS()`). For production resilience, use a package with retry mechanisms or integrate Kavenegar’s API directly with exponential backoff.