PHPackages                             ibnnajjaar/dhiraagu-sms-laravel - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. ibnnajjaar/dhiraagu-sms-laravel

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

ibnnajjaar/dhiraagu-sms-laravel
===============================

A simple, lightweight package for sending SMS using Dhiraagu SMS API

v1.1.0(6mo ago)196MITPHPPHP ^8.4CI passing

Since Oct 20Pushed 6mo agoCompare

[ Source](https://github.com/ibnnajjaar/dhiraagu-sms-laravel)[ Packagist](https://packagist.org/packages/ibnnajjaar/dhiraagu-sms-laravel)[ Docs](https://github.com/ibnnajjaar/dhiraagu-sms-laravel)[ RSS](/packages/ibnnajjaar-dhiraagu-sms-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

Dhiraagu SMS for Laravel
========================

[](#dhiraagu-sms-for-laravel)

[![Tests](https://github.com/ibnnajjaar/dhiraagu-sms-laravel/workflows/Tests/badge.svg)](https://github.com/ibnnajjaar/dhiraagu-sms-laravel/actions)[![Code Coverage Badge](./.github/coverage.svg)](./.github/coverage.svg)

A simple, lightweight package for sending SMS via **new** Dhiraagu SMS API.

Requirements
------------

[](#requirements)

- PHP 8.4 or higher
- Laravel 12.x or higher
- Composer

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

[](#installation)

Install the package using Composer:

```
composer require ibnnajjaar/dhiraagu-sms-laravel
```

You can optionally publish configuration file

```
php artisan vendor:publish --tag=dhiraagu_sms
```

Setup &amp; Configuration
-------------------------

[](#setup--configuration)

### Environment Setup

[](#environment-setup)

Before using the package, you need to obtain credentials (username and password) from the Dhiraagu Bulk SMS portal and add them to your environment variables:

```
DHIRAAGU_SMS_USERNAME=your_username
DHIRAAGU_SMS_PASSWORD=your_password
#DHIRAAGU_SMS_DEV_MOBILE_NUMBER=your_dev_mobile_number
```

> \[!NOTE\] You can also add the dev mobile number to your environment variables. This is useful for testing purposes when you don't want to send SMS to real recipients during development. When this variable is set, all SMS will be sent to the specified dev mobile number instead of the actual recipients. This can be used when you do not have a separate testing account.

Usage
-----

[](#usage)

### Sending SMS to Multiple Recipients

[](#sending-sms-to-multiple-recipients)

When sending SMS to multiple recipients, first create a DhiraaguSMSData object with the recipient list and message:

```
use IbnNajjaar\DhiraaguSMSLaravel\DataObjects\DhiraaguSMSData;

// Option 1: Using the fromArray method
$data = DhiraaguSMSData::fromArray([
    'recipients' => '7xxxxxx, +9607xxxxxx, 9xxxxxx', // string of recipients separated by comma
    'message' => 'Hello World', // message to be sent
]);

// Option 2: Using fluent methods
$data = new DhiraaguSMSData()
    ->setRecipients('7xxxxxx, +9607xxxxxx, 9xxxxxx')
    ->setMessage('Hello World');
```

Then, to send the SMS, use the DhiraaguSMS class.

```
use IbnNajjaar\DhiraaguSMSLaravel\DhiraaguSMS;

app(DhiraaguSMS::class)->send($data);
```

### Sending SMS to a Single Recipient

[](#sending-sms-to-a-single-recipient)

For convenience, you can send SMS to a single recipient without creating a data object: **Note:** This uses a **get** method to send the SMS.

```
app(DhiraaguSMS::class)->sendToSingleRecipient($data);
```

### Development/testing: override recipients with alwaysSendTo

[](#developmenttesting-override-recipients-with-alwayssendto)

In development or testing, you can force all outgoing SMS to be delivered to specific numbers, ignoring the recipients provided in your data. This helps prevent accidentally sending messages to real users.

Using `DhiraaguSMS::alwaysSendTo` You can define or clear an override at runtime. The override applies only when the optional condition is true.

Signature:

```
public static function DhiraaguSMS::alwaysSendTo(?string $recipients, bool|Closure $condition = true): void
```

The below examples show how to use this method. You can define the override in your service provider's register method.

```
use IbnNajjaar\DhiraaguSMSLaravel\DhiraaguSMS;

// Always send to a single number
DhiraaguSMS::alwaysSendTo('9609876543');

// Always send to multiple numbers (comma-separated)
DhiraaguSMS::alwaysSendTo('9609876543,9607654321');

// Apply only in local environment (boolean condition)
DhiraaguSMS::alwaysSendTo('9609876543', app()->environment('local'));

// Apply only in staging (Closure condition)
DhiraaguSMS::alwaysSendTo('9609876543', fn () => app()->environment('staging'));

// Clear the override (reverts to config fallback, if set)
DhiraaguSMS::alwaysSendTo(null); // or pass an empty string

// You can also completely clear any override (including config fallback effect at runtime)
\IbnNajjaar\DhiraaguSMSLaravel\DhiraaguSMS::clearAlwaysSendTo();
```

Notes:

- Recipients passed to alwaysSendTo are normalized and deduplicated, just like regular recipients. Invalid numbers are removed.
- When an override is active, SendMessageToMultipleRecipients will use the full override array as the destination; SendMessageToSingleRecipient will use only the first override number.
- If you do not call alwaysSendTo and have DHIRAAGU\_SMS\_DEV\_MOBILE\_NUMBER configured, that config value will be used automatically as an override.
- You may call alwaysSendTo from your own service provider's register method if you prefer centralized setup.

### Using Dependency Injection

[](#using-dependency-injection)

The DhiraaguSMS class is registered as a singleton, so you can use dependency injection in your services:

```
use IbnNajjaar\DhiraaguSMSLaravel\DhiraaguSMS;
use IbnNajjaar\DhiraaguSMSLaravel\DataObjects\DhiraaguSMSData;

class NotificationService
{
    public function __construct(private DhiraaguSMS $dhiraaguSMS)
    {
    }

    public function handle(DhiraaguSMSData $data)
    {
        $this->dhiraaguSMS->send($data);
    }
}
```

Security Considerations
-----------------------

[](#security-considerations)

### Credential Management

[](#credential-management)

- Store credentials in environment variables
- Never commit credentials to version control
- Add .env to your .gitignore file

Testing
-------

[](#testing)

```
composer test
```

### Test Coverage

[](#test-coverage)

You can generate a coverage report without requiring Xdebug or PCOV by running tests under phpdbg via the provided Composer script:

```
composer test-coverage
```

This will execute Pest with code coverage enabled and write a Clover report to coverage.xml. If you prefer to run Pest directly, ensure you have a coverage driver installed/enabled (e.g., Xdebug with XDEBUG\_MODE=coverage):

```
XDEBUG_MODE=coverage vendor/bin/pest --coverage
```

Changelog
---------

[](#changelog)

See CHANGELOG.md for release notes: [CHANGELOG.md](./CHANGELOG.md)

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Contributors
------------

[](#contributors)

- [Hussain Afeef](https://abunooh.com)

Support
-------

[](#support)

For questions, issues, or feature requests, please open an issue on GitHub.

Alternatives
------------

[](#alternatives)

- [Dhiraagu SMS](https://github.com/dash8x/dhiraagu-sms) by [dash8x](https://github.com/dash8x) - A framework-agnostic PHP library for sending SMS via the Dhiraagu SMS API. This is the most popular package for integrating with the Dhiraagu SMS service.

License
-------

[](#license)

This package is open-sourced software licensed under the MIT License.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance66

Regular maintenance activity

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.9% 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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

204d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e504a7bf85cca1e38f07b4c4ae89e76bd46f9cd9c1517770ae2b8a209460d3c?d=identicon)[ibnnajjaar](/maintainers/ibnnajjaar)

---

Top Contributors

[![ibnnajjaar](https://avatars.githubusercontent.com/u/7188633?v=4)](https://github.com/ibnnajjaar "ibnnajjaar (39 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

laravelnotificationsmsdhiraaguibnnajjaar

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ibnnajjaar-dhiraagu-sms-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/ibnnajjaar-dhiraagu-sms-laravel/health.svg)](https://phpackages.com/packages/ibnnajjaar-dhiraagu-sms-laravel)
```

###  Alternatives

[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[gr8shivam/laravel-sms-api

A modern, flexible Laravel package for integrating any SMS gateway with REST API support

10138.4k](/packages/gr8shivam-laravel-sms-api)[ghanem/laravel-smsmisr

Send SMS and SMS Notification via SMS Misr for Laravel

194.8k](/packages/ghanem-laravel-smsmisr)

PHPackages © 2026

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