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 Php

Kavenegar Php Laravel Package

erfanhemmati/kavenegar-php

PHP client for the Kavenegar RESTful SMS API. Install via Composer, set your API key, then send SMS to one or multiple recipients using KavenegarApi::Send. Includes basic exception handling and response details (messageid, status, cost).

View on GitHub
Deep Wiki
Context7

A PHP wrapper for Kavenegar's API

Frequently asked questions about Kavenegar Php
How do I integrate this Kavenegar SMS package into a Laravel application?
Install via Composer with `composer require kavenegar/php`, then instantiate the client in a service or controller using your API key from `.env`. For better Laravel integration, bind it to the service container: `$this->app->singleton(KavenegarApi::class, fn($app) => new KavenegarApi(config('services.kavenegar.api_key')));`.
Does this package support Laravel’s queue system for async SMS sending?
No, it’s synchronous by default. Wrap `KavenegarApi::Send()` in a Laravel job (e.g., `SendSmsJob`) to queue SMS delivery. Use `ShouldQueue` and dispatch it via `dispatch(new SendSmsJob($phone, $message))` for background processing.
What Laravel versions and PHP versions are supported?
The package works with PHP 7.4+ and Laravel 8+. It lacks PHP 8.1+ features like named arguments, so ensure your project aligns with these constraints. Test thoroughly if using Laravel 9+.
How do I handle failed SMS deliveries or retries?
The package throws `ApiException` or `HttpException` for errors. For retries, implement a custom job with `ShouldQueue` and use Laravel’s `retryAfter()` or a package like `spatie/laravel-queue-retries` for exponential backoff.
Can I use this for high-volume SMS campaigns or is it only for OTPs?
It’s suitable for both, but for high-volume campaigns, queue the SMS jobs to avoid timeouts. Monitor queue backlogs with Laravel Horizon and consider batch processing (e.g., chunking recipients).
How do I securely store the Kavenegar API key in Laravel?
Store it in `.env` (e.g., `KAVENEGAR_API_KEY=your_key`) and access it via `config('services.kavenegar.api_key')`. For production, use Laravel’s encrypted `.env` or a secrets manager like AWS Secrets Manager.
Does this package support inbound SMS or webhook callbacks?
No, it’s designed for outbound SMS only. For inbound SMS or webhooks, you’ll need to integrate Kavenegar’s webhook endpoints directly or use a middleware to validate and process callbacks.
How can I mock this SMS API for testing in Laravel?
Manually mock the `KavenegarApi` class in tests by extending it or using Laravel’s `Mockery` facade. For example: `$mockApi = Mockery::mock(KavenegarApi::class)->shouldReceive('Send')->andReturn([...]);`. No built-in test double exists.
Are there alternatives if I need more features like templates or scheduling?
For templates or scheduling, consider extending this package or switching to a provider like Twilio (via `laravel-notification-channels/twilio`) or a Laravel-specific SMS package like `spatie/laravel-sms-notifications`.
How do I log SMS costs or responses for auditing in Laravel?
Access the `cost` field in the response object and log it to a database table (e.g., `sms_logs`) using Laravel’s `DB::table()` or Eloquent. Create an observer or job to process `KavenegarApi::Send()` responses post-delivery.
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