PHPackages                             skuipers/sms-client - 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. skuipers/sms-client

ActiveLibrary

skuipers/sms-client
===================

A generic SMS client library. Supports multiple swappable drivers.

07.0k↓43.8%PHP

Since May 21Pushed 12mo agoCompare

[ Source](https://github.com/SKuipers/sms-client)[ Packagist](https://packagist.org/packages/skuipers/sms-client)[ RSS](/packages/skuipers-sms-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

sms-client
==========

[](#sms-client)

[![Build Status](https://camo.githubusercontent.com/0f44a33fb4dcd5cd8925ad73410c68bde07a1f67b7a5ee72abb5fd0ecc903039/68747470733a2f2f7472617669732d63692e6f72672f6d6174746865776264616c792f736d732d636c69656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/matthewbdaly/sms-client)

A generic SMS client library. Supports multiple swappable drivers, so that you're never tied to just one provider.

This library is aimed squarely at sending SMS messages only, and I don't plan to add support for other functionality. The idea is to create one library that should be able to work with any provider that has a driver for the purpose of sending SMS messages.

Drivers
-------

[](#drivers)

It currently ships with the following drivers:

- Clockwork
- Nexmo
- TextLocal
- Twilio
- AWS SNS (requires installation of `aws/aws-sdk-php`)
- Mail (for mail-to-SMS gateways)
- O2SK (O2 Slovakia)

In addition, it also has the following drivers for test purposes:

- RequestBin
- Null
- Log

The RequestBin sends the POST request to the specified RequestBin path for debugging. The Null driver does nothing, while the Log driver accepts a PSR3 logger and uses it to log the request.

Example Usage
-------------

[](#example-usage)

**Null**

```
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Response;
use Matthewbdaly\SMS\Drivers\Null;
use Matthewbdaly\SMS\Client;

$guzzle = new GuzzleClient;
$resp = new Response;
$driver = new Null($guzzle, $resp);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'content' => 'Just testing',
];
$client->send($msg);
```

**Log**

```
use Matthewbdaly\SMS\Drivers\Log;
use Matthewbdaly\SMS\Client;
use Psr\Log\LoggerInterface;

$driver = new Log($logger); // $logger should be an implementation of Psr\Log\LoggerInterface
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'content' => 'Just testing',
];
$client->send($msg);
```

**RequestBin**

```
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Response;
use Matthewbdaly\SMS\Drivers\RequestBin;
use Matthewbdaly\SMS\Client;

$guzzle = new GuzzleClient;
$resp = new Response;
$driver = new RequestBin($guzzle, $resp, [
    'path' => 'MY_REQUESTBIN_PATH',
]);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'content' => 'Just testing',
];
$client->send($msg);
```

**Clockwork**

```
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Response;
use Matthewbdaly\SMS\Drivers\Clockwork;
use Matthewbdaly\SMS\Client;

$guzzle = new GuzzleClient;
$resp = new Response;
$driver = new Clockwork($guzzle, $resp, [
    'api_key' => 'MY_CLOCKWORK_API_KEY',
]);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'content' => 'Just testing',
];
$client->send($msg);
```

**Nexmo**

```
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Response;
use Matthewbdaly\SMS\Drivers\Nexmo;
use Matthewbdaly\SMS\Client;

$guzzle = new GuzzleClient;
$resp = new Response;
$driver = new Nexmo($guzzle, $resp, [
    'api_key' => 'MY_NEXMO_API_KEY',
    'api_secret' => 'MY_NEXMO_API_SECRET',
]);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'from'    => 'Test User',
    'content' => 'Just testing',
];
$client->send($msg);
```

**AWS SNS**

```
use Matthewbdaly\SMS\Client;
use Matthewbdaly\SMS\Drivers\Aws;

$config = [
    'api_key'    => 'foo',
    'api_secret' => 'bar',
    'api_region' => 'ap-southeast-2'
];
$driver = new Aws($config);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'from'    => 'Test User',
    'content' => 'Just testing',
];
$client->send($msg);
```

**Mail**

```
use Matthewbdaly\SMS\Client;
use Matthewbdaly\SMS\Drivers\Mail;
use Matthewbdaly\SMS\Contracts\Mailer;

$config = [
    'domain' => 'my.sms-gateway.com'
];
$driver = new Mail($config);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'content' => 'Just testing',
];
$client->send($msg);
```

**TextLocal**

```
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Response;
use Matthewbdaly\SMS\Drivers\TextLocal;
use Matthewbdaly\SMS\Client;

$guzzle = new GuzzleClient;
$resp = new Response;
$driver = new TextLocal($guzzle, $resp, [
    'api_key' => 'MY_TEXTLOCAL_API_KEY',
]);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'from'    => 'Test User',
    'content' => 'Just testing',
];
$client->send($msg);
```

**Twilio**

```
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Response;
use Matthewbdaly\SMS\Drivers\Twilio;
use Matthewbdaly\SMS\Client;

$guzzle = new GuzzleClient;
$resp = new Response;
$driver = new Twilio($guzzle, $resp, [
    'account_id' => 'MY_TWILIO_ACCOUNT_ID',
    'api_token' => 'MY_TWILIO_API_TOKEN',
]);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'from'      => '+44 01234 567890',
    'content' => 'Just testing',
];
$client->send($msg);
```

**O2SK**

```
use GuzzleHttp\Client as GuzzleClient;
use Matthewbdaly\SMS\Drivers\O2SK;
use Matthewbdaly\SMS\Client;

$driver = new O2SK(new GuzzleClient, [
    'apiKey' => 'MY_O2SK_API_KEY',
]);
$client = new Client($driver);
$msg = [
    'message' => 'Testing message',
    'sender' => ['text' => 'Tester'],
    'recipients' => [
        ['phonenr' => '+421911000000']
    ]
];
$client->send($msg);
```

Mail driver
-----------

[](#mail-driver)

I have implemented a mail driver at `Matthewbdaly\SMS\Drivers\Mail`, but it's very basic and may not work with a lot of mail-to-SMS gateways out of the box. It accepts an instance of the `Matthewbdaly\SMS\Contracts\Mailer` interface as the first argument, and the config array as the second.

I've included the class `Matthewbdaly\SMS\PHPMailAdapter` in the library as a very basic implementation of the mailer interface, but it's deliberately very basic - it's just a very thin wrapper around the PHP `mail()` function. You will almost certainly want to create your own implementation for your own use case - for instance, if you're using Laravel you might create a wrapper class for the `Mail` facade.

The mail driver will nearly always be slower and less reliable than the HTTP-based ones, so if you have to integrate with a provider that doesn't yet have a driver, but does have a REST API, you're probably better off creating an API driver for it. If you do need to work with a mail-to-SMS gateway, you're quite likely to find that you need to extend `Matthewbdaly\SMS\Drivers\Mail` to amend the functionality.

Laravel and Lumen integration
-----------------------------

[](#laravel-and-lumen-integration)

Using Laravel or Lumen? You probably want to use [my integration package](https://packagist.org/packages/matthewbdaly/laravel-sms) rather than this one, since that includes a service provider, as well as the `SMS` facade and easier configuration.

Creating your own driver
------------------------

[](#creating-your-own-driver)

It's easy to create your own driver - just implement the `Matthewbdaly\SMS\Contracts\Driver` interface. You can use whatever method is most appropriate for sending the SMS - for instance, if your provider has a mail-to-SMS gateway, you can happily use Swiftmailer or PHPMailer in your driver to send emails, or if they have a REST API you can use Guzzle.

You can pass any configuration options required in the `config` array in the constructor of the driver. Please ensure that your driver has tests using PHPSpec (see the existing drivers for examples), and that it meets the coding standard (the package includes a PHP Codesniffer configuration for that reason).

If you've created a new driver, feel free to submit a pull request and I'll consider including it.

TODO
----

[](#todo)

I have plans for a 2.0 release which include:

- More drivers! If you're using an SMS provider that isn't on the list and you'd like to see support for it in this library, go ahead and create your own driver and submit a pull request for it.
- Remove dependency on Guzzle and replace it with HTTPlug so it doesn't need a specific implementation.
- Add a factory for resolving the drivers automatically.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 97.3% 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/deb9127b980adb709b86262078120b177a097524cc20381156ed7e0bb294bdd1?d=identicon)[SKuipers](/maintainers/SKuipers)

---

Top Contributors

[![matthewbdaly](https://avatars.githubusercontent.com/u/450801?v=4)](https://github.com/matthewbdaly "matthewbdaly (144 commits)")[![laramoore](https://avatars.githubusercontent.com/u/50185207?v=4)](https://github.com/laramoore "laramoore (2 commits)")[![mohavee](https://avatars.githubusercontent.com/u/24735528?v=4)](https://github.com/mohavee "mohavee (1 commits)")[![SKuipers](https://avatars.githubusercontent.com/u/897700?v=4)](https://github.com/SKuipers "SKuipers (1 commits)")

### Embed Badge

![Health badge](/badges/skuipers-sms-client/health.svg)

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

PHPackages © 2026

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