PHPackages                             texhub/oson-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. [HTTP &amp; Networking](/categories/http)
4. /
5. texhub/oson-sms

ActiveLibrary[HTTP &amp; Networking](/categories/http)

texhub/oson-sms
===============

OsonSMS gateway SDK for any PHP framework with first-class Laravel support: send SMS, bulk messaging, delivery responses and optional SHA-256 request signing.

v1.0.1(1mo ago)10MITPHPPHP ^8.2

Since Jun 1Pushed 1mo agoCompare

[ Source](https://github.com/TexhubPro/oson-sms)[ Packagist](https://packagist.org/packages/texhub/oson-sms)[ Docs](https://texhub.pro)[ RSS](/packages/texhub-oson-sms/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

TexHub · OsonSMS
================

[](#texhub--osonsms)

**English** · [Русский](README.ru.md)

[![License: MIT](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/d91d3d1139cf0d8faaa80eeeeac7d3c59c9319e56960ef81c948e4160be4c4c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e322d3737376262342e737667)](composer.json)[![Laravel](https://camo.githubusercontent.com/3e9242504354dbb5afd360f9a1ec114126b2caddb73d9e789d9102c3285d2b05/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d3131253230253743253230313225323025374325323031332d6666326432302e737667)](#laravel)

A clean, framework-agnostic PHP SDK for the **OsonSMS** gateway — send single and bulk SMS — with first-class **Laravel** support.

> Works in plain PHP and any framework. Laravel gets auto-discovery, a config file and a facade for free.

---

Features
--------

[](#features)

- **Send SMS** with a fluent message builder or a one-line shortcut
- **Bulk send** that never throws — each result carries its own success/error
- **Bearer-token auth** + optional **SHA-256 `str_hash`** signing
- **Pluggable HTTP transport** — cURL by default; inject your own for testing
- **Typed responses &amp; exceptions** (`ApiException` with code / message / error\_type)
- **Fully unit-tested**, no network needed

---

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

[](#installation)

```
composer require texhub/oson-sms
```

Requirements: **PHP ≥ 8.2** with the `curl`, `json` and `hash` extensions.

---

Quick start (plain PHP)
-----------------------

[](#quick-start-plain-php)

```
use TexHub\OsonSms\OsonSms;

$oson = OsonSms::make(
    login: 'YOUR_LOGIN',
    token: 'YOUR_TOKEN',
    sender: 'YOUR_SENDER',
);

$response = $oson->send('992900123456', 'Привет! Это тест OsonSMS.');

echo $response->messageId;  // msg_id
echo $response->txnId;      // txn_id
```

### Fluent builder

[](#fluent-builder)

```
use TexHub\OsonSms\Requests\SmsMessage;

$oson->send(
    SmsMessage::make('992900123456', 'Ваш код: 1234')
        ->from('MyShop')        // override the default sender
        ->txnId('order-42')     // idempotency key (auto-generated otherwise)
);
```

### Bulk (tolerant — never throws)

[](#bulk-tolerant--never-throws)

```
$results = $oson->sms()->sendMany([
    SmsMessage::make('992900000001', 'Сообщение 1'),
    SmsMessage::make('992900000002', 'Сообщение 2'),
]);

foreach ($results as $r) {
    if ($r['ok']) {
        echo "sent: {$r['response']->messageId}\n";
    } else {
        echo "failed: {$r['error']->getMessage()}\n";
    }
}
```

---

Authentication
--------------

[](#authentication)

By default the SDK authenticates with the **Bearer token** in the `Authorization` header (as in the OsonSMS sample), sending these parameters:

ParamSource`from`sender (config or per-message)`phone_number`recipient`msg`text`txn_id`idempotency key (auto)`login`config login### Optional `str_hash` signature

[](#optional-str_hash-signature)

If your account requires a signed request, set a hash secret and the SDK appends a `str_hash` parameter:

```
str_hash = SHA256( txn_id ; login ; sender ; phone_number ; hash_secret )

```

```
$oson = OsonSms::fromArray([
    'login' => '...', 'token' => '...', 'sender' => '...',
    'hash_secret' => 'YOUR_API_HASH',
]);
```

> If your terminal uses a different field order, compute it yourself with `new Signature($secret)` `->hash($yourString)`.

---

Error handling
--------------

[](#error-handling)

```
use TexHub\OsonSms\Exceptions\ApiException;
use TexHub\OsonSms\Exceptions\TransportException;
use TexHub\OsonSms\Exceptions\OsonSmsException;

try {
    $oson->send('992900123456', 'Hi');
} catch (ApiException $e) {
    $e->errorCode;   // error.code
    $e->apiMessage;  // error.msg
    $e->errorType;   // error.error_type
} catch (TransportException $e) {
    // network failure
} catch (OsonSmsException $e) {
    // base type — also covers invalid responses
}
```

The API signals errors with a JSON body: `{ "error": { "code": ..., "msg": "...", "error_type": "..." } }`.

---

 Laravel
-------------------------------------------

[](#-laravel)

The service provider and `OsonSms` facade are **auto-discovered**. Publish the config:

```
php artisan vendor:publish --tag=oson-sms-config
```

Add credentials to `.env`:

```
OSON_SMS_LOGIN=your_login
OSON_SMS_TOKEN=your_token
OSON_SMS_SENDER=YourSender
# optional:
OSON_SMS_HASH_SECRET=
OSON_SMS_SERVER=https://api.osonsms.com/sendsms_v1.php
OSON_SMS_TIMEOUT=30
```

Use the facade:

```
use TexHub\OsonSms\Laravel\OsonSms;
use TexHub\OsonSms\Requests\SmsMessage;

OsonSms::send('992900123456', 'Привет из Laravel!');

OsonSms::send(
    SmsMessage::make('992900123456', 'Ваш код: 1234')->txnId('order-'.$order->id)
);
```

…or inject it:

```
public function notify(\TexHub\OsonSms\OsonSms $oson) { /* ... */ }
```

---

Testing
-------

[](#testing)

Inject the fake transport to test without hitting the network:

```
use TexHub\OsonSms\OsonSms;
use TexHub\OsonSms\Config;
use TexHub\OsonSms\Tests\Support\FakeTransport;

$transport = (new FakeTransport())->willReturnJson(['msg_id' => '1', 'txn_id' => 'a']);
$oson = new OsonSms(new Config('login', 'token', 'Sender'), $transport);

$oson->send('992900123456', 'Hi');
// assert on $transport->lastQuery / lastHeaders / lastUrl
```

Run the package test suite:

```
composer install
composer test          # or: vendor/bin/phpunit
```

---

Architecture
------------

[](#architecture)

```
src/
├── OsonSms.php              # entry point — sms() / send()
├── Config.php               # immutable configuration
├── Signature.php            # optional SHA-256 str_hash signer
├── Http/                    # Transport interface, CurlTransport, Response
├── Requests/SmsMessage.php  # fluent message builder
├── Clients/SmsClient.php    # send() / sendMany()
├── Exceptions/              # ApiException, TransportException, …
└── Laravel/                 # ServiceProvider + Facade

```

---

License
-------

[](#license)

MIT © TexHub Pro — built by Mahmudi Shodmehr.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance93

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~19 days

Total

2

Last Release

34d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/217647751?v=4)[TexHub Pro](/maintainers/TexhubPro)[@TexhubPro](https://github.com/TexhubPro)

---

Top Contributors

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

---

Tags

laravelosonsmsphpsdksmssms-gatewaytajikistanphplaravelsmssms-gatewayosonsmsTajikistantexhuboson

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/texhub-oson-sms/health.svg)

```
[![Health](https://phpackages.com/badges/texhub-oson-sms/health.svg)](https://phpackages.com/packages/texhub-oson-sms)
```

###  Alternatives

[basement-chat/basement-chat

Add a real-time chat widget to your Laravel application.

4984.1k](/packages/basement-chat-basement-chat)[openapi/openapi-sdk

Minimal and agnostic PHP SDK for Openapi® (https://openapi.com)

161.7k1](/packages/openapi-openapi-sdk)

PHPackages © 2026

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