PHPackages                             pralhadstha/sms-gateways - 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. pralhadstha/sms-gateways

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

pralhadstha/sms-gateways
========================

Framework-agnostic PHP SMS gateway with pluggable providers (Sparrow SMS and more).

v1.0.0(today)01↑2900%MITPHPPHP &gt;=8.1CI passing

Since Jul 28Pushed todayCompare

[ Source](https://github.com/pralhadstha/sms-gateways)[ Packagist](https://packagist.org/packages/pralhadstha/sms-gateways)[ RSS](/packages/pralhadstha-sms-gateways/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (7)Versions (2)Used By (0)

SMS Gateway
===========

[](#sms-gateway)

[![CI](https://github.com/pralhadstha/sms-gateways/actions/workflows/ci.yml/badge.svg)](https://github.com/pralhadstha/sms-gateways/actions/workflows/ci.yml)[![Latest Version](https://camo.githubusercontent.com/6f2a82496975f333a20d40afae8ed49bbd7e87d4b7f680dc0f7a9f0c3fd0f4c2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7072616c686164737468612f736d732d67617465776179732e737667)](https://packagist.org/packages/pralhadstha/sms-gateways)[![License](https://camo.githubusercontent.com/d45804d5e32b38e0fc8b3f5d90cc045751cf4a9e9989dbe9e77ba0a377b9e2fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7072616c686164737468612f736d732d67617465776179732e737667)](LICENSE)

A small, framework-agnostic PHP library for sending SMS through pluggable providers. No framework, no hard HTTP dependency — providers talk to any [PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP client, so it drops into Laravel, Symfony, or plain PHP alike.

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

[](#requirements)

- PHP 8.1+
- A PSR-18 HTTP client and PSR-17 factories (e.g. `guzzlehttp/guzzle` + `nyholm/psr7`, or `symfony/http-client`) — only for HTTP-based providers.

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

[](#installation)

```
composer require pralhadstha/sms-gateways
```

For an HTTP provider you also need a client and factories, for example:

```
composer require nyholm/psr7 guzzlehttp/guzzle
```

Usage
-----

[](#usage)

Every provider implements `Pralhadstha\Sms\SmsGateway`:

```
use Pralhadstha\Sms\SmsGateway;
use Pralhadstha\Sms\SmsMessage;

function notify(SmsGateway $sms): void
{
    $result = $sms->send(new SmsMessage(
        to: '+9779800000000',
        text: 'Your account has been activated.',
    ));

    if ($result->failed()) {
        // inspect $result->error and $result->raw
    }
}
```

### Sparrow SMS (Nepal)

[](#sparrow-sms-nepal)

```
use GuzzleHttp\Client;
use Nyholm\Psr7\Factory\Psr17Factory;
use Pralhadstha\Sms\Gateway\SparrowGateway;

$factory = new Psr17Factory();

$sms = new SparrowGateway(
    client: new Client(),
    requestFactory: $factory,
    streamFactory: $factory,
    token: getenv('SPARROW_TOKEN'),
    from: 'YourIdentity',
);
```

### Disabling / testing

[](#disabling--testing)

- `Pralhadstha\Sms\Gateway\NullGateway` — accepts every message and reports success without sending. Use it when no credentials are configured.
- `Pralhadstha\Sms\Gateway\ArrayGateway` — records messages in memory so your application's tests can assert on what would have been sent:

```
$sms = new ArrayGateway();
$sms->send(new SmsMessage('123', 'hi'));

assert($sms->count() === 1);
assert($sms->lastMessage()->text === 'hi');
```

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

[](#error-handling)

`send()` returns an `SmsResult`:

- **Provider rejection** (non-2xx, error in body) → `SmsResult::failed()` is `true`; read `->error` and `->raw`.
- **Transport failure** (DNS, timeout, connection) → throws `Pralhadstha\Sms\Exception\SmsException`.

Adding a provider
-----------------

[](#adding-a-provider)

Implement `SmsGateway` and return an `SmsResult`. HTTP providers should accept PSR-18/PSR-17 abstractions in the constructor — see [`SparrowGateway`](src/Gateway/SparrowGateway.php) as the reference.

```
final class MyProviderGateway implements SmsGateway
{
    public function send(SmsMessage $message): SmsResult
    {
        // ... call the provider, map the response ...
        return SmsResult::success();
    }
}
```

Development
-----------

[](#development)

```
composer install
composer test     # PHPUnit
composer stan     # PHPStan (level 8)
composer cs       # PHP-CS-Fixer (dry run); composer cs-fix to apply
```

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d46fb8b473d604d2f5eb4e27451ef88b44e10a430c0a0ce89b4e501fcfe95b2?d=identicon)[pralhad](/maintainers/pralhad)

---

Top Contributors

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

---

Tags

psr-18notificationsmsgatewaynepalsparrow

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pralhadstha-sms-gateways/health.svg)

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.1B4.1k](/packages/guzzlehttp-psr7)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k17](/packages/tempest-framework)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

36789.4k2](/packages/telnyx-telnyx-php)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[mollie/mollie-api-php

Mollie API client library for PHP. Mollie is a European Payment Service provider and offers international payment methods such as Mastercard, VISA, American Express and PayPal, and local payment methods such as iDEAL, Bancontact, SOFORT Banking, SEPA direct debit, Belfius Direct Net, KBC Payment Button and various gift cards such as Podiumcadeaukaart and fashioncheque.

60316.0M89](/packages/mollie-mollie-api-php)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

185702.8k44](/packages/laudis-neo4j-php-client)

PHPackages © 2026

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