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 Package

erfanhemmati/kavenegar

Laravel integration for the Kavenegar SMS API. Install via Composer, register the service provider and facade, publish the config, and set your API key in config/kavenegar.php to start sending SMS from your Laravel app.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • SMS Gateway Integration: The package provides a clean abstraction for integrating Kavenegar (Iran’s SMS gateway) into Laravel applications, aligning well with use cases requiring SMS notifications, OTPs, or transactional messaging.
  • Facade-Based Design: Leverages Laravel’s service container and facades, ensuring consistency with existing Laravel patterns (e.g., Mail, Cache).
  • Decoupled Logic: Encapsulates SMS-related logic behind a service provider, promoting separation of concerns and testability.

Integration Feasibility

  • Laravel Compatibility: Officially supports Laravel 4–10, but Laravel 10+ may require validation for newer PHP features (e.g., attributes, stricter typing).
  • Dependency Clarity: Requires kavenegar/php (core SDK) and minimal Laravel dependencies (no heavy frameworks like Symfony).
  • Configuration-Driven: Centralized config via vendor:publish, reducing boilerplate and enabling environment-specific overrides (e.g., staging/production API keys).

Technical Risk

  • Deprecated Laravel 4/5 Support: Risk of compatibility issues with modern Laravel (e.g., dependency injection, event system changes).
  • Undocumented Edge Cases: No clear examples for batch sending, template management, or error handling (e.g., rate limits, API failures).
  • No Type Safety: PHP SDK lacks type hints; Laravel facade may not enforce return types (e.g., send() could return bool|array|string).
  • Testing Gaps: No PHPUnit examples or mocking guidance for unit tests.

Key Questions

  1. API Key Management:
    • How will API keys be secured (env vars, Vault, or Laravel’s config)?
    • Is there a fallback for key rotation without downtime?
  2. Error Handling:
    • Are Kavenegar’s HTTP errors (e.g., 429 Too Many Requests) translated into Laravel exceptions?
    • How will retries be implemented for transient failures?
  3. Logging:
    • Is there built-in logging for SMS delivery status (success/failure)?
    • Can logs be integrated with Laravel’s monolog?
  4. Performance:
    • Does the package support async sending (queues/jobs) to avoid blocking HTTP requests?
    • What’s the overhead of facade calls vs. direct SDK usage?
  5. Testing:
    • How will SMS responses be mocked in CI/CD pipelines?
    • Are there contracts/interfaces for dependency injection testing?

Integration Approach

Stack Fit

  • Ideal For:
    • Laravel 8/9/10 apps with PHP 8.1+ (modern type safety, attributes).
    • Projects requiring OTP verification, alerts, or transactional SMS.
    • Teams already using Laravel’s facade pattern (e.g., Mail::send()).
  • Avoid If:
    • Using Lumen (missing service container features).
    • Need advanced SMS analytics (package lacks tracking hooks).
    • Requiring multi-gateway fallback (hardcoded to Kavenegar).

Migration Path

  1. Assessment Phase:
    • Audit existing SMS logic (e.g., Twilio, custom HTTP clients).
    • Map use cases to Kavenegar’s API docs (e.g., sendSms, verifyLookup).
  2. Pilot Integration:
    • Replace one SMS endpoint (e.g., OTP) with the facade:
      Kavenegar::send('1234567890', '1234', 'Your OTP: {otp}', ['otp' => $code]);
      
    • Test with Kavenegar’s sandbox.
  3. Full Rollout:
    • Publish config (php artisan vendor:publish --provider="Kavenegar\Laravel\ServiceProvider").
    • Replace direct HTTP calls with facade calls.
    • Add queue jobs for async sending (see below).

Compatibility

  • PHP Version: Requires PHP 7.4+ (Laravel 8+). Test with php -v and composer validate.
  • Laravel Features:
    • Service Container: Works with Laravel’s DI (bind Kavenegar interface if needed).
    • Events: No built-in events, but can dispatch custom events post-send.
    • Queues: Not natively supported; wrap facade calls in SendSmsJob:
      use Kavenegar\Facades\Kavenegar;
      use Illuminate\Bus\Queueable;
      
      class SendSmsJob implements Queueable {
          public function handle() {
              Kavenegar::send(...);
          }
      }
      
  • Database: No ORM hooks, but can log SMS status to a sms_logs table.

Sequencing

  1. Pre-Reqs:
    • Obtain Kavenegar API key (sandbox first).
    • Update composer.json and run composer install.
  2. Core Setup:
    • Register provider/alias in config/app.php.
    • Publish config (php artisan vendor:publish).
  3. Testing:
    • Unit test facade calls with Mockery:
      $mock = Mockery::mock('alias:Kavenegar')->shouldReceive('send')->once()->andReturnTrue();
      
    • Integration test with real API (use .env overrides).
  4. Production:
    • Deploy with feature flags for gradual rollout.
    • Monitor logs for KavenegarException (customize error handling).

Operational Impact

Maintenance

  • Vendor Lock-In: Tight coupling to Kavenegar’s API; switching gateways requires rewriting facade logic.
  • Dependency Updates:
    • Monitor kavenegar/php for breaking changes (no semantic versioning in README).
    • Laravel updates may break if package uses deprecated features (e.g., Illuminate\Support\Facades\Input).
  • Configuration Drift:
    • Risk of misconfigured API keys in merged PRs; enforce CI checks for .env validation.

Support

  • Debugging:
    • Limited community support (0 stars, no issues/PRs). Debugging will rely on:
      • Kavenegar’s docs.
      • Laravel’s config:clear and cache:clear for config issues.
    • Log Kavenegar’s raw responses for troubleshooting:
      Kavenegar::setDebug(true); // If available
      
  • SLAs:
    • No guarantees on Kavenegar’s uptime (SMS gateways are external).
    • Implement circuit breakers for critical paths (e.g., spatie/laravel-circuitbreaker).

Scaling

  • Rate Limits:
    • Kavenegar enforces rate limits. Implement:
      • Exponential backoff for retries.
      • Queue throttling (e.g., redis-queue with sleep() in job).
    • Monitor failed_jobs table for throttled jobs.
  • Async Processing:
    • Offload sending to queues to avoid timeouts:
      SendSmsJob::dispatch($to, $template, $params)->delay(now()->addSeconds(5));
      
  • Horizontal Scaling:
    • Stateless facade calls scale automatically; no shared memory issues.

Failure Modes

Failure Scenario Impact Mitigation
Kavenegar API downtime SMS delivery fails Fallback to email or local caching.
Invalid API key All SMS calls fail silently Validate key in boot() and log errors.
Rate limit exceeded Jobs queue up indefinitely Implement retry logic with jitter.
Template parsing errors SMS sent with incorrect placeholders Validate templates before sending.
Database connection issues Async jobs fail to log Use failed_jobs table + dead-letter queue.

Ramp-Up

  • Onboarding Time: 2–4 hours for basic setup (longer if customizing).
    • Blockers:
      • Undocumented config options (e.g., default_sender).
      • Lack of TypeScript/IDE support (PHPStorm hints may be limited).
  • Training Needs:
    • Developers: Familiarity with Laravel facades and Kavenegar’s API.
    • DevOps: Monitoring for SMS delivery metrics (e.g., Prometheus exporter).
  • Documentation Gaps:
    • No examples for:
      • Webhook handling (Kavenegar’s callback URLs).
      • Multi-language templates.
      • Bulk SMS (if supported).
    • Workaround: Use Kavenegar’s PHP SDK docs as reference.

Recommendations

  1. **Enhance the Package
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.
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
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope