PHPackages                             mix-code/jawaly-sms - 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. mix-code/jawaly-sms

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

mix-code/jawaly-sms
===================

Laravel and PHP package to send SMS notifications using the 4jawaly SMS API gateway.

v1.0.2(7mo ago)010[3 PRs](https://github.com/mix-code/jawaly-sms/pulls)MITPHPPHP ^8.1CI passing

Since Aug 31Pushed 1mo agoCompare

[ Source](https://github.com/mix-code/jawaly-sms)[ Packagist](https://packagist.org/packages/mix-code/jawaly-sms)[ Docs](https://github.com/mix-code/jawaly-sms)[ GitHub Sponsors](https://github.com/mix-code)[ RSS](/packages/mix-code-jawaly-sms/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (7)Used By (0)

4Jawaly SMS
===========

[](#4jawaly-sms)

[![Latest Version on Packagist](https://camo.githubusercontent.com/304a887ee04dcd12540d41e6dff6f063d49f449530cc2f936b34fbdc6815a543/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d69782d636f64652f6a6177616c792d736d732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mix-code/jawaly-sms)[![Tests](https://camo.githubusercontent.com/934abde15325d7f84fb9613ca2af45a9327e5018f8072c51d848ea29b5f9270a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d69782d636f64652f6a6177616c792d736d732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/mix-code/jawaly-sms/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/2dfe48ddf0b5f386ccb05b907d18ce0fc31978307a406afa7688a3fb532089f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d69782d636f64652f6a6177616c792d736d732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mix-code/jawaly-sms)[![License](https://camo.githubusercontent.com/84710464f0482aeb57ae281c47af54c458c4e966a12d14376002387b99549544/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d69782d636f64652f6a6177616c792d736d732e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

A Laravel package to send SMS messages using the **4Jawaly SMS API**.

- Clean, consistent responses via a typed value object: `MixCode\JawalySms\SmsResponse`
- Use a **Facade** (`JawalySms`) or inject the **service class** (`MixCode\JawalySms\JawalySms`)
- Helpful error data without throwing exceptions to the application layer

---

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

[](#installation)

```
composer require mix-code/jawaly-sms
```

Publish the config (optional if you want to customize):

```
php artisan jawaly-sms:install
```

### Configuration

[](#configuration)

Add credentials to your `.env`:

```
JAWALY_SMS_BASE_URL=https://api.jawaly.com.sa/api/
JAWALY_SMS_API_KEY=your_app_id
JAWALY_SMS_API_SECRET=your_app_secret
```

Config file (`config/jawaly-sms.php`) keys used by the package:

```
return [
    'base_url'  => env('JAWALY_SMS_BASE_URL'),
    'api_key'   => env('JAWALY_SMS_API_KEY'),
    'api_secret'=> env('JAWALY_SMS_API_SECRET'),
];
```

---

Usage
-----

[](#usage)

### Via the Facade

[](#via-the-facade)

```
use MixCode\JawalySms\Facades\JawalySms;

// 1) Get senders (names only)
$response = JawalySms::senders(namesOnly: true);
if ($response->success) {
    // array of strings
    $senders = $response->data['senders'];
}

// 2) Check balance
$balance = JawalySms::balance();
if ($balance->success) {
    $amount = $balance->data['balance']; // e.g. 150
}

// 3) Send SMS
$result = JawalySms::sendSMS(
    message: 'Hello from Jawaly! 🚀',
    numbers: ['9665xxxxxxx', '9665yyyyyyy'],
    sender: 'YourBrand'
);
if ($result->success) {
    $jobId = $result->data['job_id'];
}
```

---

API Methods
-----------

[](#api-methods)

All methods return **`MixCode\JawalySms\SmsResponse`**.

### `senders(bool $namesOnly = false): SmsResponse`

[](#sendersbool-namesonly--false-smsresponse)

Fetch available senders.

**Success data shape**

```
[
    'senders' => [
        // if $namesOnly = true → ["Sender1", "Sender2", ...]
        // else → array of sender objects from 4Jawaly API
    ],
]
```

**Error response**

```
$response->success === false;
$response->error;  // string message
$response->status; // HTTP status code or null
$response->body;   // raw response body (array|null)
```

---

### `balance(): SmsResponse`

[](#balance-smsresponse)

Get remaining SMS balance.

**Success data shape**

```
[
    'balance' => 150,
]
```

---

### `sendSMS(string $message, array $numbers, string $sender): SmsResponse`

[](#sendsmsstring-message-array-numbers-string-sender-smsresponse)

Send a single message to one or more numbers from a specific sender name.

**Payload example**

```
$message = 'Hello from Jawaly!';
$numbers = ['9665xxxxxxx', '9665yyyyyyy'];
$sender  = 'YourBrand';
```

**Success data shape**

```
[
    'job_id' => 'abc123',
]
```

**Possible error shape**

```
$response->success === false;
$response->error;  // "Invalid number" or API message
$response->status; // e.g. 422/400/500
$response->body;   // raw API body
```

---

Response Object: `SmsResponse`
------------------------------

[](#response-object-smsresponse)

A simple value object consistently returned by all methods.

```
namespace MixCode\JawalySms;

class SmsResponse
{
    public function __construct(
        public bool $success,
        public mixed $data = null,
        public ?string $error = null,
        public ?int $status = null,
        public mixed $body = null,
    ) {}

    public static function success(mixed $data): self
    {
        return new self(true, $data);
    }

    public static function error(string $error, ?int $status = null, mixed $body = null): self
    {
        return new self(false, null, $error, $status, $body);
    }
}
```

**Typical usage**

```
$res = JawalySms::balance();
if ($res->success) {
    $amount = $res->data['balance'];
} else {
    logger()->error('Jawaly error', [
        'error' => $res->error,
        'status' => $res->status,
        'body' => $res->body,
    ]);
}
```

---

Testing
-------

[](#testing)

This package is test-friendly with Laravel's HTTP fakes.

```
composer test
# or
vendor/bin/pest
```

---

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for recent changes.

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

[](#contributing)

PRs welcome! Please see [CONTRIBUTING](CONTRIBUTING.md).

Security
--------

[](#security)

Please review [our security policy](SECURITY.md) for how to report vulnerabilities.

Credits
-------

[](#credits)

- [MixCode](https://github.com/mix-code)
- [All Contributors](CONTRIBUTORS.md)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

38

—

LowBetter than 84% of packages

Maintenance84

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.5% 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 ~8 days

Total

3

Last Release

233d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/10d476babd579e5a75399ebb785e0b1c25ad2dc9ae7b58f2242e8a87f4a4ac5e?d=identicon)[mix-code](/maintainers/mix-code)

---

Top Contributors

[![moaalaa](https://avatars.githubusercontent.com/u/22417282?v=4)](https://github.com/moaalaa "moaalaa (13 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

phpapilaravelnotificationsmsmessaginggatewaytext messagemix-codeSms Integration4jawaly4jawaly-sms

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/mix-code-jawaly-sms/health.svg)

```
[![Health](https://phpackages.com/badges/mix-code-jawaly-sms/health.svg)](https://phpackages.com/packages/mix-code-jawaly-sms)
```

###  Alternatives

[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)
