PHPackages                             sepiosky/kavenegar-notifications-channel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. sepiosky/kavenegar-notifications-channel

ActiveLaravel-package

sepiosky/kavenegar-notifications-channel
========================================

Kavenegar Notifications Channel for Laravel

03PHP

Since Nov 28Pushed 5y ago1 watchersCompare

[ Source](https://github.com/sepiosky/KavenegarNotificationsChannel)[ Packagist](https://packagist.org/packages/sepiosky/kavenegar-notifications-channel)[ RSS](/packages/sepiosky-kavenegar-notifications-channel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Kavenegar Notifications Channel for Laravel
===========================================

[](#kavenegar-notifications-channel-for-laravel)

This package makes it easy to send SMS notification using [Kavenegar API](https://kavenegar.com) (both [SMS webservice](https://kavenegar.com/register-webservice-sms.html) and [OTP webservice](https://kavenegar.com/sms/verification)) with Laravel.

Contents
--------

[](#contents)

- [Installation](#installation)
- [Usage](#usage)
    - [Plain Text SMS Notification](#plain-text-sms-notification)
    - [OTP SMS Notification](#otp-sms-notification)
    - [Routing Messages](#routing-messages)
    - [Available Message methods](#available-message-methods)
    - [Handling Response](#handling-response)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require sepiosky/kavenegar-notifications-channel
```

Then, add your Kavenegar API credentials to `config/services.php`: (note that `sender` is only used in SMS webservice(not OTP). it also is optional)

```
// config/services.php
'kavenegar' => [
    'key' => env('KAVENEGAR_API_KEY'),
    'sender' => env('KAVENEGAR_SENDER')
],
```

And register Kavenegar service provider in `config/app.php` (in Laravel 5.5 and later this will be done automatically):

```
// config/app.php
'providers' => [
    ...
    NotificationChannels\Kavenegar\KavenegarServiceProvider::class,
    ...
],
```

Usage
-----

[](#usage)

after installing you can use Kavenegar in your Notifications by registering `KavenegarChannel` in `via()` method:

### Plain Text SMS Notification

[](#plain-text-sms-notification)

the `method` attibute of `KavenegarMessage` is `sms` by default:

```
use NotificationChannels\Kavenegar\KavenegarChannel;
use NotificationChannels\Kavenegar\KavenegarMessage;
use Illuminate\Notifications\Notification;

class WelcomeMessage extends Notification
{
    public function via($notifiable)
    {
        return [KavenegarChannel::class];
    }

    public function toSMS($notifiable)
    {
        return KavenegarMessage::create()
            ->method('sms')
            //its optional since KavenegarMessage has it deafult method set sms
            ->to($notifiable->phone)
            ->Message('Dear '.$notifiable->username.'! Thanks for joining us');
    }
}
```

### OTP SMS Notification

[](#otp-sms-notification)

For this type of notifications you should set `method('otp')` on returning `KavenegarMessage`:

```
use NotificationChannels\Kavenegar\KavenegarChannel;
use NotificationChannels\Kavenegar\KavenegarMessage;
use Illuminate\Notifications\Notification;

class VerifyAccount extends Notification
{
    public function via($notifiable)
    {
        return [KavenegarChannel::class];
    }

    public function toSMS($notifiable)
    {
        $url = env('APP_URL');
        return KavenegarMessage::create()
            ->method('otp')->to($notifiable->phone)
            ->token('1425')->template('registerVerifyTemplate')
            ->token2('please')->token10($url);
    }
}
```

note that only `token` and `template` are required (you should create and verify your template on your Kavenegar pannel first) and other tokens are optional.

### Routing Messages

[](#routing-messages)

You can either provide phone number of the receptor to the `to($phone)` method like shown in examples or add a `routeNotificationForSms()` method in your notifiable model:

```
/**
 * Route notifications for the Kavenegar channel.
 *
 * @return int
 */
public function routeNotificationForSms()
{
    return $this->phone_number;
}
```

### Available Message methods

[](#available-message-methods)

- `method($method)`: (string) Method of message . (sms/otp)
- `to($phone)`: (integer) Receptor's phone number.
- `template($template)`: (string) Template name of your message (Required for OTP messages)
- `token($token)`: (string) First token of your template (equired for OTP messages)
- `token2($token)`, `token3($token)`, `token10($token)`, `token20($token)`,: (string) Optional tokens for OTP messages
- `message($message)`: (string) Body of your message (Required for SMS messages)

For API's input formats please refer the [Kavenegar REST API's docs](https://kavenegar.com/rest.html).

### Handling Response

[](#handling-response)

You can make use of the [notification events](https://laravel.com/docs/8.x/notifications#notification-events) to handle the response from Kavenegar. On success, your event listener will recieve a array object with various fields as appropriate to the notification type.

For a complete list of response fields, please refer the [Kavenegar REST API's docs](https://kavenegar.com/rest.html).

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0deb7f183aa87ceea85df6dc8fec96327c91ecade7adcd6c60faba2b256cd738?d=identicon)[sepiosky](/maintainers/sepiosky)

---

Top Contributors

[![sepiosky](https://avatars.githubusercontent.com/u/61506518?v=4)](https://github.com/sepiosky "sepiosky (4 commits)")

### Embed Badge

![Health badge](/badges/sepiosky-kavenegar-notifications-channel/health.svg)

```
[![Health](https://phpackages.com/badges/sepiosky-kavenegar-notifications-channel/health.svg)](https://phpackages.com/packages/sepiosky-kavenegar-notifications-channel)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
