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

laravel 4 and 5 kavenegar integration

Frequently asked questions about Kavenegar
How do I install Kavenegar Laravel and get started?
Run `composer require kavenegar/laravel`, register the `ServiceProvider` and `Facade` in `config/app.php`, then publish the config with `php artisan vendor:publish`. Finally, add your API key to `config/kavenegar.php`. The package supports Laravel 4–10.
Does this package support Laravel 10 and PHP 8.1+?
Yes, the package officially supports Laravel 10, but some newer PHP features (like attributes) may require manual validation. Test thoroughly if using PHP 8.1+. The README recommends using the latest Laravel version for best compatibility.
How do I send an SMS using the facade?
Use `Kavenegar::send($recipient, $sender, $message, $parameters)` where `$recipient` is the phone number, `$sender` is your sender ID, and `$parameters` are optional placeholders (e.g., for OTPs). Example: `Kavenegar::send('1234567890', '1234', 'Your OTP: {otp}', ['otp' => $code]).`
Can I use this package with Laravel queues for async SMS sending?
No, the package doesn’t natively support queues. However, you can wrap facade calls in a `Queueable` job (e.g., `SendSmsJob`) to defer SMS sending. Example: `Kavenegar::dispatch(new SendSmsJob($recipient, $message));`
How do I handle errors like rate limits (HTTP 429) or API failures?
The package doesn’t translate Kavenegar’s HTTP errors into Laravel exceptions by default. You’ll need to catch exceptions manually (e.g., `try-catch`) or extend the facade to add retry logic. Check the underlying `kavenegar/php` SDK for error codes.
Is there built-in logging for SMS delivery status?
No, the package doesn’t include logging. You can manually log responses (e.g., success/failure) using Laravel’s `Log` facade or integrate with Monolog by extending the service provider to hook into the SDK’s callbacks.
Can I mock Kavenegar responses in unit tests?
Yes, you can mock the facade or the underlying `kavenegar/php` SDK. Use Laravel’s `MockFacade` or replace the service provider binding in tests. Example: `$this->app->instance('kavenegar', MockKavenegar::class);`
What if I need to rotate my API key without downtime?
Store the API key in environment variables (e.g., `.env`) instead of `config/kavenegar.php` for easier rotation. Use `config('kavenegar.apikey')` to fetch it dynamically, allowing you to update `.env` without republishing the config.
Are there alternatives to this package for Laravel SMS integration?
Yes, alternatives include `spatie/laravel-sms` (multi-provider) or direct integration with the `kavenegar/php` SDK. However, this package offers a Laravel-specific facade and publishable config, simplifying setup for Kavenegar users in Iran.
How do I handle template-based SMS (e.g., predefined Kavenegar templates)?
The package doesn’t natively support template IDs, but you can pass parameters to replace placeholders in the message string (e.g., `['otp' => $code]`). For advanced template management, extend the facade or use the raw `kavenegar/php` SDK methods.
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