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

Laravel Laravel Package

kavenegar/laravel

Laravel integration for Kavenegar SMS/voice API. Install via Composer, register the service provider and facade, publish the config, and set your Kavenegar API key. Then call the Kavenegar facade anywhere in your app to send messages.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • SMS Integration: The package provides a clean, facade-based abstraction for Kavenegar’s SMS API, aligning well with Laravel’s service container and facade patterns. It abstracts HTTP requests, retries, and response handling, reducing boilerplate for SMS operations (send, verify, etc.).
  • Event-Driven Potential: While not explicitly event-driven, the package could be extended to emit events (e.g., SmsSent, SmsFailed) for observability or workflows (e.g., retries, analytics).
  • Modularity: The package is self-contained, with minimal dependencies (guzzlehttp/guzzle), making it easy to integrate without polluting the global namespace or requiring deep architectural changes.

Integration Feasibility

  • Laravel Compatibility: Supports Laravel 4–10, but Laravel 10+ may require adjustments for newer features (e.g., dependency injection, HTTP client changes). The package uses Laravel’s ServiceProvider and Facade patterns, which remain stable.
  • API Abstraction: Wraps Kavenegar’s REST API (e.g., Kavenegar::send($message, $receptor, $sender)), reducing coupling to the underlying HTTP client. This simplifies future API updates (e.g., switching to GraphQL or SDK).
  • Configuration: Centralized config via vendor:publish ensures environment-specific API keys and settings (e.g., sandbox vs. production) without hardcoding.

Technical Risk

  • Deprecation Risk: The package hasn’t seen updates since March 2024, and the underlying kavenegar/php library (v1.0.0) is also outdated. Risk of breaking changes if Kavenegar’s API evolves (e.g., new endpoints, auth methods).
  • Laravel 10+ Gaps: Potential issues with:
    • HTTP Client: The package uses Guzzle v6, but Laravel 10+ defaults to Guzzle v7+. May need a wrapper or adapter.
    • Dependency Injection: Older Laravel versions may lack native support for newer DI features (e.g., bindIf).
    • Testing: No PHPUnit tests in the repo; manual testing required for edge cases (e.g., rate limits, invalid API keys).
  • Error Handling: Basic error handling (e.g., retries, logging) is manual. Could benefit from Laravel’s Illuminate\Support\Facades\Log or custom exceptions.
  • Type Safety: No PHP 8+ type hints or return types, increasing runtime error risk.

Key Questions

  1. API Stability: Has Kavenegar’s API changed since the package’s last update? Are there undocumented breaking changes?
  2. Performance: Does the package batch requests or support async sending? If not, could this impact throughput for high-volume SMS?
  3. Monitoring: How are failures logged/retried? Are there hooks for observability (e.g., Prometheus metrics)?
  4. Testing: What’s the test coverage for edge cases (e.g., invalid numbers, rate limits, sandbox mode)?
  5. Alternatives: Should we use the official Kavenegar PHP SDK directly for more control, or does this package’s abstraction justify the risk?
  6. Maintenance: Is there a community or maintainer to address issues? If not, are we prepared to fork/maintain it?

Integration Approach

Stack Fit

  • Laravel Ecosystem: The package is Laravel-native, leveraging:
    • Service Providers: For bootstrapping and binding the Kavenegar client to the container.
    • Facades: For concise syntax (e.g., Kavenegar::send()).
    • Config Publishing: For environment-specific settings (API key, sandbox mode).
  • HTTP Layer: Uses Guzzle v6, which is compatible with Laravel’s HTTP client but may need a shim for Laravel 10+.
  • Event System: Can be extended to integrate with Laravel’s events (e.g., sent, failed) for workflows like:
    • Retry queues (via Laravel Queues).
    • Analytics (e.g., storing SMS logs in a database).
    • Notifications (e.g., Slack alerts for failures).

Migration Path

  1. Assessment Phase:
    • Audit current SMS logic (e.g., Twilio, custom scripts) to identify gaps/overlaps.
    • Test the package in a staging environment with Laravel 10+ to catch compatibility issues early.
  2. Installation:
    • Add to composer.json and publish config:
      composer require kavenegar/laravel
      php artisan vendor:publish --provider="Kavenegar\Laravel\ServiceProvider"
      
    • Configure .env with KAVENEGAR_API_KEY and sandbox/production settings.
  3. Incremental Replacement:
    • Replace ad-hoc SMS calls with the facade (e.g., Kavenegar::send()).
    • Use Laravel’s Service Container to bind the client for dependency injection:
      $this->app->bind(KavenegarClient::class, function ($app) {
          return new KavenegarClient($app['config']['kavenegar.api_key']);
      });
      
  4. Testing:
    • Write integration tests for critical paths (e.g., OTP sending, failure scenarios).
    • Mock the HTTP client to avoid hitting Kavenegar’s API during CI.
  5. Deprecation Plan:

Compatibility

Laravel Feature Compatibility Mitigation
Laravel 10+ HTTP Client ❌ Uses Guzzle v6 (L10+ defaults to v7) Create a Guzzle v7 adapter or use Laravel’s HTTP client directly.
Dependency Injection ✅ Works, but lacks type hints Add PHP 8+ types or use bindIf for conditional binding.
Queued Jobs ✅ Supports async via Laravel Queues Wrap Kavenegar::send() in a job class.
Events ❌ No built-in events Extend the package or emit custom events post-send.
Testing ❌ No tests Write test cases for critical paths (e.g., KavenegarTestCase).

Sequencing

  1. Phase 1: Core Integration (2–3 weeks)
    • Replace all SMS logic with the facade.
    • Implement basic error handling (e.g., log failures to storage/logs).
  2. Phase 2: Observability (1 week)
    • Add event listeners for SmsSent/SmsFailed.
    • Integrate with Laravel Horizon for queue monitoring.
  3. Phase 3: Scaling (Ongoing)
    • Implement rate limiting (e.g., via throttle middleware).
    • Add support for batch sending if needed.
  4. Phase 4: Maintenance (Ongoing)
    • Monitor for API changes and update the package or fork as needed.

Operational Impact

Maintenance

  • Pros:
    • Centralized Config: API keys and settings are environment-specific (via .env).
    • Facade Abstraction: Reduces code changes if Kavenegar’s API evolves (e.g., new endpoints).
  • Cons:
    • Abandoned Package: No recent updates; risk of technical debt if Kavenegar’s API changes.
    • No Tests: Manual testing required for edge cases (e.g., rate limits, invalid inputs).
    • Dependency Risk: Relies on kavenegar/php (v1.0.0), which may lack updates.
  • Mitigation:
    • Fork the Package: Maintain a private fork to patch issues or add features (e.g., events, type hints).
    • Document Workarounds: Track known limitations (e.g., Guzzle version conflicts) in a CONTRIBUTING.md.
    • Automated Testing: Add a CI pipeline to test the package against Kavenegar’s API (e.g., using Laravel Pest).

Support

  • Pros:
    • Simple API: Easy to debug (e.g., Kavenegar::send() is self-documenting).
    • Community: GitHub issues may exist for common problems (though inactive).
  • Cons:
    • No Official Support: No SLAs or documentation for troubleshooting.
    • Language Barrier: Kavenegar’s support may be Persian-language only.
  • Mitigation:
    • Internal Runbook: Document common issues (e.g., "API key expired," "rate limits").
    • Fallback Plan: Maintain a script to call Kavenegar’s API directly as a backup.

**Scal

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