PHPackages                             turndale/smsonline - 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. turndale/smsonline

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

turndale/smsonline
==================

A Laravel Package for SMSOnlineGH integration for laravel 11 and above

v1.1.0(4mo ago)0123MITPHPPHP ^8.1|^8.2|^8.3

Since Jan 22Pushed 4mo agoCompare

[ Source](https://github.com/turndale/smsonline)[ Packagist](https://packagist.org/packages/turndale/smsonline)[ Docs](https://stephenasare.dev/)[ RSS](/packages/turndale-smsonline/feed)WikiDiscussions 1.x Synced today

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

SMSOnlineGH Laravel Package
===========================

[](#smsonlinegh-laravel-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5b02999772c1982d0c8502be25e98bd70f5653dabd785f589c966280891aaf6e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7475726e64616c652f736d736f6e6c696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/turndale/smsonline)[![Total Downloads](https://camo.githubusercontent.com/33ff4a4f8f3d8923dedb3d468dbcf1d4697d4716d6ff4f563ee85d5a414807a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7475726e64616c652f736d736f6e6c696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/turndale/smsonline)[![License](https://camo.githubusercontent.com/b9e887d0fe054f008746f2353994f81450a7da1065508f111525d82f07c7fda1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7475726e64616c652f736d736f6e6c696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/turndale/smsonline)

A comprehensive Laravel package for integrating with the [SMSOnlineGH](https://smsonlinegh.com/) API. This package provides a fluent interface for sending SMS, scheduling messages, checking account balance, and managing scheduled campaigns.

Features
--------

[](#features)

- **Fluent Interface:** Easy-to-use chainable methods for constructing messages.
- **Helper Function:** specific `sms()` helper for quick access.
- **Scheduling:** Native support for scheduling messages with timezone offsets.
- **Account Management:** Check balance and cancel scheduled batches easily.
- **Laravel Support:** Compatible with Laravel 11.x and 12.x.
- **PHP 8.1+ Support**

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

[](#installation)

You can install the package via composer:

```
composer require turndale/smsonline
```

### Configuration

[](#configuration)

Publish the configuration file to your application:

```
php artisan vendor:publish --provider="Turndale\SmsOnline\SmsOnlineServiceProvider" --tag="config"
```

This will create a `config/smsonline.php` file. You should then add your SMSOnlineGH credentials to your `.env` file:

```
SMSONLINE_API_KEY=your_api_key_here
SMSONLINE_DEFAULT_SENDER=YourSenderID
```

Usage
-----

[](#usage)

### Sending a Basic SMS

[](#sending-a-basic-sms)

You can use the `sms()` helper function or the Facade to send messages. All methods return an `SmsResponse` object with convenient methods for accessing the response data.

```
use Turndale\SmsOnline\Facades\SmsOnline;

// Using the Helper
$response = sms('MyCompany')
    ->message('Hello from Helper!')
    ->destinations(['0244123456'])
    ->send();

// Using the Facade
$response = SmsOnline::sender('MyCompany')
    ->message('Hello from Facade!')
    ->destinations(['0244123456'])
    ->send();

if ($response->successful()) {
    echo "Message sent successfully!";
    echo "Batch ID: " . $response->getBatchId();
} else {
    echo "Failed to send message: " . $response->getError();
}
```

### Sending SMS with Default Sender

[](#sending-sms-with-default-sender)

If you've set the `SMSONLINE_DEFAULT_SENDER` environment variable in your `.env` file, you don't need to explicitly pass the sender when sending messages. This makes your code cleaner and allows you to manage the sender globally.

```
SMSONLINE_DEFAULT_SENDER=MyCompany
```

Then you can send messages without specifying a sender:

```
use Turndale\SmsOnline\Facades\SmsOnline;

// Using the Helper (no sender parameter needed)
$response = sms()
    ->message('Hello using default sender!')
    ->destinations(['0244000000'])
    ->send();

// Using the Facade (no sender() method needed)
$response = SmsOnline::message('Hello using default sender!')
    ->destinations(['0244000000'])
    ->send();

if ($response->successful()) {
    echo "Message sent successfully!";
}
```

### Method Chaining

[](#method-chaining)

The package is designed to be fluent:

```
// Helper
sms()
    ->sender('MyBrand')
    ->message('Code: 1234')
    ->destinations(['0571234567'])
    ->send();

// Facade
SmsOnline::sender('MyBrand')
    ->message('Code: 1234')
    ->destinations(['0571234567'])
    ->send();
```

### Scheduling Messages

[](#scheduling-messages)

To schedule a message for later delivery, use the `schedule()` method. Pass the date/time string (YYYY-MM-DD HH:MM) and optionally a timezone offset.

```
// Helper
sms('EventOrg')
    ->message('Event starts in 1 hour.')
    ->destinations(['0244123456'])
    ->schedule('2026-12-25 08:00', '+00:00')
    ->send();

// Facade
SmsOnline::sender('EventOrg')
    ->message('Event starts in 1 hour.')
    ->destinations(['0244123456'])
    ->schedule('2026-12-25 08:00', '+00:00')
    ->send();
```

### Checking Account Balance

[](#checking-account-balance)

Retrieve your current account balance.

```
// Helper
$response = sms()->balance();

// Facade
$response = SmsOnline::balance();

$data = $response->json();
$balance = $data['data']['balance'] ?? 0;
echo "Current Balance: " . $balance;
```

### Cancelling a Scheduled Message

[](#cancelling-a-scheduled-message)

If you need to cancel a scheduled batch, use the `cancelScheduled` method with the Batch ID returned from the sending response.

```
// $batchId = 'cfa19ba67f94fbd6b19c067b0c87ed4f'; // ID from the send response

// Helper
$response = sms()->cancelScheduled($batchId);

// Facade
$response = SmsOnline::cancelScheduled($batchId);

if ($response->successful()) {
    echo "Scheduled message cancelled.";
}
```

### Working with Responses

[](#working-with-responses)

All API methods (`send()`, `balance()`, `cancelScheduled()`) return an `SmsResponse` object that provides convenient methods for accessing the response data.

#### Converting Response to Array

[](#converting-response-to-array)

```
$response = sms()
    ->message('Hello World')
    ->destinations(['0244123456'])
    ->send();

// Get the full response as an array
$data = $response->toArray();

// Or use json() method (same result)
$data = $response->json();

// Access specific keys with dot notation
$batchId = $response->json('data.batch_id');
$status = $response->json('status');

// With default value for missing keys
$value = $response->json('nonexistent.key', 'default_value');
```

#### Accessing Data Directly

[](#accessing-data-directly)

```
// Get the 'data' portion of the response
$data = $response->getData();

// Access nested keys within data
$batchId = $response->getData('batch_id');
$credits = $response->getData('credits');

// Shortcut for batch ID
$batchId = $response->getBatchId();
```

#### Array Access

[](#array-access)

The response object supports array access for convenience:

```
$response = sms()->message('Test')->destinations(['0244123456'])->send();

// Access like an array
$status = $response['status'];
$batchId = $response['data']['batch_id'];

// Check if key exists
if (isset($response['data'])) {
    // ...
}
```

#### Status Helpers

[](#status-helpers)

```
$response = sms()->message('Test')->destinations(['0244123456'])->send();

// Check if request was successful (2xx status code)
if ($response->successful()) {
    echo "Success!";
}

// Alternative method
if ($response->ok()) {
    echo "Success!";
}

// Check if request failed (4xx or 5xx status code)
if ($response->failed()) {
    echo "Error: " . $response->getError();
}

// Check specific error types
if ($response->clientError()) {
    echo "Client error (4xx)";
}

if ($response->serverError()) {
    echo "Server error (5xx)";
}

// Get HTTP status code
$statusCode = $response->status(); // e.g., 200, 401, 500
```

#### Error Handling

[](#error-handling)

```
$response = sms()->message('Test')->destinations(['0244123456'])->send();

if ($response->failed()) {
    // Get error message from response
    $error = $response->getError();

    // Get raw response body
    $body = $response->body();

    // Get status code for logging
    $status = $response->status();

    Log::error("SMS failed", [
        'error' => $error,
        'status' => $status,
        'body' => $body,
    ]);
}
```

#### JSON Serialization

[](#json-serialization)

The response can be easily serialized to JSON:

```
$response = sms()->message('Test')->destinations(['0244123456'])->send();

// Automatically converts to JSON
$json = json_encode($response);

// Or cast to string (pretty printed JSON)
echo (string) $response;
```

#### Accessing the Original Laravel Response

[](#accessing-the-original-laravel-response)

If you need access to the underlying Laravel HTTP response:

```
$response = sms()->message('Test')->destinations(['0244123456'])->send();

// Get the original Illuminate\Http\Client\Response
$laravelResponse = $response->getResponse();

// Access headers
$headers = $response->headers();
```

Testing
-------

[](#testing)

You can run the tests with:

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Stephen Asare](https://github.com/stephenasaredev)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance74

Regular maintenance activity

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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 ~7 days

Total

3

Last Release

148d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ad63f515427a7f3f34d8c23c8344f91fec1cba8ef7c8cb98da769b42c7990970?d=identicon)[hellofromsteve](/maintainers/hellofromsteve)

---

Top Contributors

[![hellofromsteve](https://avatars.githubusercontent.com/u/131690895?v=4)](https://github.com/hellofromsteve "hellofromsteve (8 commits)")

---

Tags

smssmsonlinelaravel-smslaravel sms packagediscussionsissue-trackingsms-laravelsmsonline laravel packageghana-sms-laravelsmsonline-ghana-laravelsmsonline-ghana-laravel-packagesms-ghana-laravelsms-laravel-packageopen-source smsonlinecontributions smsonline

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/turndale-smsonline/health.svg)

```
[![Health](https://phpackages.com/badges/turndale-smsonline/health.svg)](https://phpackages.com/packages/turndale-smsonline)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k90.5k1](/packages/mike-bronner-laravel-model-caching)[illuminate/auth

The Illuminate Auth package.

10528.2M1.2k](/packages/illuminate-auth)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

319270.8k6](/packages/tzsk-sms)[illuminate/routing

The Illuminate Routing package.

1419.2M3.0k](/packages/illuminate-routing)

PHPackages © 2026

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