Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Kavenegar Laravel Notification Laravel Package

erfanhemmati/kavenegar-laravel-notification

Laravel 5.3/5.4 notification channel for sending SMS via Kavenegar. Configure your API key (and optional sender) in services.php, add the service provider, then use KavenegarChannel in notifications and routeNotificationForSms to supply the recipient number.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • Laravel Native Integration: Leverages Laravel’s built-in notification system, aligning with Laravel’s architecture (5.3/5.4) and avoiding reinventing the wheel.
    • Channel-Based Design: Follows Laravel’s notification channels pattern (e.g., MailChannel, DatabaseChannel), enabling modularity and extensibility.
    • Minimal Overhead: Lightweight package focused solely on SMS notifications, reducing bloat compared to monolithic solutions.
    • Event-Driven: Can integrate with Laravel’s event system (e.g., sent, failed hooks) for observability or retries.
  • Cons:

    • Legacy Laravel Support: Targets Laravel 5.3/5.4, which may introduce compatibility risks if migrating to newer Laravel versions (e.g., 8.x/9.x/10.x) without updates.
    • Limited Features: No built-in support for advanced SMS features (e.g., templates, scheduling, or delivery reports) beyond basic sending.
    • Vendor Lock-in: Tied to Kavenegar’s API, which may have rate limits, pricing changes, or regional restrictions.

Integration Feasibility

  • High for Greenfield Projects: Ideal for new Laravel apps targeting Iran (Kavenegar’s primary market) or testing SMS notifications.
  • Moderate for Existing Systems:
    • Requires minimal code changes (add service provider, config, and routeNotificationForSms).
    • Backward Compatibility: Works with Laravel’s notification system, so existing Notification classes can be extended with minimal effort.
    • Testing Overhead: May need to mock Kavenegar’s API for CI/CD pipelines.

Technical Risk

  • API Dependency Risk: Kavenegar’s API stability (e.g., rate limits, downtime) could impact production reliability.
  • Laravel Version Risk: No active maintenance for newer Laravel versions; may require forks or custom patches.
  • Error Handling: Limited documentation on retries, logging, or fallback mechanisms for failed SMS deliveries.
  • Security: API key exposure in .env is standard but should be audited for compliance (e.g., secret scanning).

Key Questions

  1. Laravel Version Compatibility:
    • Is the team using Laravel 5.3/5.4, or would a newer version require a fork/maintenance?
    • Are there plans to upgrade Laravel, and if so, how would this package be adapted?
  2. SMS Use Cases:
    • Are notifications one-time (e.g., OTPs) or recurring (e.g., alerts)? Recurring use may need rate-limiting logic.
    • Does the app require SMS templates, scheduling, or delivery receipts? If so, custom logic may be needed.
  3. Fallback Mechanisms:
    • How should failed SMS deliveries be handled (e.g., email fallback, retries, or user alerts)?
  4. Cost and Scaling:
    • What are Kavenegar’s pricing tiers, and how does the app’s SMS volume align with them?
    • Are there regional restrictions (e.g., sender number validation for specific countries)?
  5. Observability:
    • How will SMS delivery success/failure be logged or monitored (e.g., Laravel logs, external tools)?
  6. Testing:
    • How will SMS notifications be tested in CI/CD (e.g., mocking Kavenegar’s API)?

Integration Approach

Stack Fit

  • Best Fit:
    • Laravel 5.3/5.4 Apps: Native integration with zero refactoring.
    • SMS-Only Workflows: Ideal for OTPs, alerts, or simple notifications.
    • Iran-Based Projects: Kavenegar is optimized for Iranian numbers/senders.
  • Partial Fit:
    • Multi-Channel Notifications: Works alongside Mail, Database, etc., but lacks advanced features (e.g., SMS templates).
    • Global Apps: May require additional logic for non-Iranian numbers (e.g., sender validation).
  • Poor Fit:
    • Laravel 8+/9+/10+: Unmaintained; would need custom adaptation.
    • Complex SMS Workflows: Missing features like scheduling, bulk sends, or analytics.

Migration Path

  1. Assessment Phase:
    • Audit existing notification logic to identify SMS use cases.
    • Verify Laravel version compatibility; plan forks if needed.
  2. Setup:
    • Install via Composer: composer require erfanhemmati/kavenegar-laravel-notification.
    • Register the service provider in config/app.php.
    • Configure config/services.php with Kavenegar credentials.
  3. Implementation:
    • Extend existing Notification classes with KavenegarChannel:
      public function via($notifiable) {
          return [KavenegarChannel::class]; // Add alongside other channels if needed
      }
      
    • Implement routeNotificationForSms() in Notifiable models (e.g., User):
      public function routeNotificationForSms() {
          return $this->phone_number;
      }
      
  4. Testing:
    • Mock Kavenegar’s API in unit tests (e.g., using Laravel’s MockHttp or a custom facade).
    • Test edge cases: invalid numbers, rate limits, and failure scenarios.
  5. Deployment:
    • Gradually roll out SMS notifications in staging, monitoring logs for failures.
    • Set up alerts for SMS delivery failures (e.g., via Laravel Horizon or external tools).

Compatibility

  • Laravel Core: Works with Laravel’s notification system but may conflict with:
    • Custom notification channels or middleware.
    • Laravel 5.5+ features (e.g., shouldQueue()) if not updated.
  • Kavenegar API:
    • Assumes API stability; test for rate limits (e.g., 1 SMS/sec by default).
    • Sender number must be pre-approved by Kavenegar for production.
  • Database:
    • No persistent storage of SMS logs; consider adding a failed_jobs table for retries.

Sequencing

  1. Phase 1: Core Integration
    • Implement basic SMS notifications for OTPs/alerts.
    • Validate delivery rates and failure modes.
  2. Phase 2: Error Handling
    • Add retries for failed SMS (e.g., using Laravel Queues).
    • Implement fallback notifications (e.g., email for critical alerts).
  3. Phase 3: Observability
    • Log SMS events to a database or external tool (e.g., Sentry, Datadog).
    • Set up dashboards for delivery metrics.
  4. Phase 4: Scaling
    • Optimize for high-volume sends (e.g., batching, queue workers).
    • Explore Kavenegar’s advanced features (if supported).

Operational Impact

Maintenance

  • Pros:
    • Low Maintenance: Minimal moving parts; updates only needed for Laravel/Kavenegar API changes.
    • Centralized Config: Credentials and settings in config/services.php and .env.
  • Cons:
    • No Active Development: Risk of breaking changes if Kavenegar’s API evolves.
    • Custom Logic: May require patches for Laravel version upgrades or new features.
  • Recommendations:
    • Monitor Kavenegar’s API docs for changes.
    • Maintain a fork if Laravel upgrades are planned.

Support

  • Pros:
    • Laravel Ecosystem: Leverages familiar debugging tools (e.g., Tinker, Log Viewer).
    • Community: Laravel’s notification system is well-documented.
  • Cons:
    • Limited Package Support: No GitHub issues/discussions to troubleshoot.
    • Kavenegar Support: Depends on third-party vendor for API issues.
  • Recommendations:
    • Document common failure modes (e.g., invalid sender, rate limits).
    • Set up a runbook for SMS delivery issues (e.g., "If SMS fails, retry 3x then notify admin").

Scaling

  • Pros:
    • Queueable: Can integrate with Laravel Queues for async sends.
    • Stateless: No server-side storage of SMS data (reduces DB load).
  • Cons:
    • Rate Limits: Kavenegar’s default limit (1 SMS/sec) may throttle high-volume apps.
    • No Built-in Batching: Requires custom logic for bulk sends.
  • Recommendations:
    • Use Laravel Queues with shouldQueue() for background processing.
    • Implement exponential backoff for retries to avoid rate limits.
    • For high volume, explore Kavenegar’s premium plans or alternative providers.

Failure Modes

Failure Scenario Impact Mitigation
Kavenegar API downtime SMS notifications fail silently. Fallback to email or in-app alerts.
Invalid sender number SMS rejected by Kavenegar. Validate sender number in config.
Rate limit exceeded Requests thrott
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle