PHPackages                             immachakata/codelsms - 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. immachakata/codelsms

ActiveLibrary

immachakata/codelsms
====================

PHP Bulk sms wrapper for Codel Sms

v2.0.0(4mo ago)3458MITPHPPHP ^8.2CI passing

Since Jul 9Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/immachakata/codels-sms-php)[ Packagist](https://packagist.org/packages/immachakata/codelsms)[ RSS](/packages/immachakata-codelsms/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (16)Used By (0)

Codel SMS PHP Wrapper
=====================

[](#codel-sms-php-wrapper)

[![CI Test Package](https://github.com/immachakata/codels-sms-php/actions/workflows/ci-test.yml/badge.svg)](https://github.com/immachakata/codels-sms-php/actions/workflows/ci-test.yml)[![Packagist Version](https://camo.githubusercontent.com/bbe029bb0bd807ebb23d0bd6b799f285850e07ec0ecbf57f8d38b952aecfcc77/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696d6d616368616b6174612f636f64656c736d73)](https://camo.githubusercontent.com/bbe029bb0bd807ebb23d0bd6b799f285850e07ec0ecbf57f8d38b952aecfcc77/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696d6d616368616b6174612f636f64656c736d73)[![Packagist Downloads](https://camo.githubusercontent.com/caf64404b0fe89fbef4814fc7a849f5c85f3f2f7cb5d9d85552082db3cdbc69c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696d6d616368616b6174612f636f64656c736d73)](https://camo.githubusercontent.com/caf64404b0fe89fbef4814fc7a849f5c85f3f2f7cb5d9d85552082db3cdbc69c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696d6d616368616b6174612f636f64656c736d73)[![Packagist License](https://camo.githubusercontent.com/4af2fab149a6427ad9d66b68a4c5a1347cb5871d6a7536e8d0d48b6115c439dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f696d6d616368616b6174612f636f64656c736d73)](https://camo.githubusercontent.com/4af2fab149a6427ad9d66b68a4c5a1347cb5871d6a7536e8d0d48b6115c439dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f696d6d616368616b6174612f636f64656c736d73)

This is an **unofficial** package for the [codel](https://sms.codel.tech) bulk sms (also known as [2waychat.com](https://2waychat.com)) designed to make sending bulk SMS messages from your PHP applications simple and efficient.

How It Works
------------

[](#how-it-works)

This wrapper interacts with the core [Codel Sms API](https://2waychat.com) and has been updated to match the March 2025 api documentation update.

It is built on top of Guzzle, a popular PHP HTTP client, to handle all communication with the Codel SMS API and provides a simple, expressive API for sending single and bulk SMS messages.

- **`Client` Class:** This is the main entry point of the library. You instantiate it with your API token, and it handles all the interactions with the Codel SMS API.
- **`Sms` Class:** A data object that represents a single SMS message, containing the destination phone number and the message text.
- **`Response` Class:** A wrapper around the Guzzle response object that provides convenient methods for accessing the response data.
- **Mocking for Tests:** The test suite uses `MockHandler` from Guzzle to simulate API calls. This ensures that your tests run quickly and do not consume your SMS credits.

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

[](#installation)

You can install the package via Composer:

```
composer require immachakata/codelsms
```

Usage
-----

[](#usage)

First, instantiate the `Client` class with your Codel SMS API token.

```
require __DIR__ . '/vendor/autoload.php';

use IsaacMachakata\CodelSms\Client;

$apiToken = 'YOUR_API_TOKEN';
$client = new Client($apiToken);
```

### Sending a Single SMS

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

To send a message to a single recipient, use the `send` method:

```
$response = $client->send('263771000001', 'Hello, this is a test message!');

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

You can also use the older method

```
$sms = Sms::new('263771000001', 'Hello, this is a test message!');
$response = $client->send($sms);
```

### Sending Bulk SMS

[](#sending-bulk-sms)

To send the same message to multiple recipients, you can pass an array of phone numbers or a comma-separated string of phone numbers, and an array of messages either indexed by phone number, or by index. Passing a string will result in all the users receiving the same message. The easiest way though would be using the `Sms` class (or whatever you'd prefer).

> **NB**: A sender id is required when sending multiple messages and an exception will be thrown if one is not provided.

**Using the `Sms` class:**

```
$response = $client->send([
    Sms::new('2637710000001', 'Message for user #1'),
    Sms::new('2637710000002', 'Message for user #2'),
]);
```

While you can specify the timestamp at which you would want the message delivered, it hasn't seemed to work when I tried it, so I'd recommend you to send your messages exactly when you want them delivered.

**Using an array:**

For this method, you can pass in an array of receivers along with either a string of the message you want them to receive, or any array with the messages you want each to receive.

```
$phoneNumbers = ['263771000001', '263772000002', '263773000003'];
$response = $client->send($phoneNumbers, 'This is a bulk message to everyone.');
```

**Using a comma-separated string:**

```
$phoneNumbers = '263771000001,263772000002,263773000003';
$response = $client->send($phoneNumbers, 'This is a bulk message to everyone.');
```

### Sending Personalized Messages in Bulk

[](#sending-personalized-messages-in-bulk)

For more advanced use cases, you can send different messages to different recipients in a single API call. Use the `personalize` method to define a template for your messages. The callback receives the phone number and should return either an `Sms` object or a string - which is the message.

```
use IsaacMachakata\CodelSms\Sms;

$users = [
    '263771000001' => ['name' => 'John', 'bill' => 150.75],
    '263772000002' => ['name' => 'Jane', 'bill' => 200.00],
];

$phoneNumbers = array_keys($users);

// the message parameter is also passed here too to the callback function
$client->personalize(function ($receiver, $data) {
    return Sms::new("Dear {$data['name']}, your bill of \${$data['bill']} is due.");
});

// The message parameter can be skipped here
$response = $client->send($phoneNumbers, $users);
```

### Setting a Sender ID

[](#setting-a-sender-id)

You can specify a custom sender ID for your messages. This can be a name or a number.

```
$txt = Sms::new('263771000001', 'Message from SenderId.');
$response = $client->from('SenderId')->send($txt);
```

You can also set the sender ID directly in the constructor:

```
$client = new Client($apiToken, 'SenderId');
$response = $client->send('263771000001', 'Message from SenderId.');
```

### Checking Your Balance

[](#checking-your-balance)

To check your remaining SMS credits, use the `getBalance` method:

```
$balance = $client->getBalance();
echo "You have {$balance} SMS credits remaining.";
```

Testing
-------

[](#testing)

The package includes a comprehensive PHPUnit test suite. To maintain the integrity of your account, the tests are designed to run with mock data and will not make any real API calls.

To run the tests, execute the following command in your terminal:

```
./vendor/bin/phpunit
```

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

[](#contributing)

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

License
-------

[](#license)

Distributed under the MIT License. See `LICENSE` for more information.

Author
------

[](#author)

- **[Isaac Machakata](https://github.com/immachakata)** - PHP Developer

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance74

Regular maintenance activity

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Recently: every ~2 days

Total

15

Last Release

141d ago

Major Versions

v1.1.8 → v2.0.02025-12-26

### Community

Maintainers

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

---

Top Contributors

[![immachakata](https://avatars.githubusercontent.com/u/108731754?v=4)](https://github.com/immachakata "immachakata (115 commits)")

---

Tags

2waychat-smsbulk-smscodel-smsphp-wrappersms-api

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/immachakata-codelsms/health.svg)

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

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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