PHPackages                             phlib/sms-length - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. phlib/sms-length

ActiveLibrary[Queues &amp; Workers](/categories/queues)

phlib/sms-length
================

SMS Length calculations, using GSM 03.38 and GSM 03.40

2.0.1(3y ago)14807.1k↓15%5[3 PRs](https://github.com/phlib/sms-length/pulls)2LGPL-3.0PHPPHP ^7.3|^8.0

Since Mar 28Pushed 1y ago5 watchersCompare

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

READMEChangelog (4)Dependencies (2)Versions (5)Used By (2)

phlib/sms-length
================

[](#phlibsms-length)

[![Code Checks](https://camo.githubusercontent.com/40c14c03ad89111d5d5cea394933155d837a978f50da9d2824f70c5c23e3d6e6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70686c69622f736d732d6c656e6774682f636f64652d636865636b732e796d6c3f6c6f676f3d676974687562)](https://github.com/phlib/sms-length/actions/workflows/code-checks.yml)[![Codecov](https://camo.githubusercontent.com/ca3511c76d6436c34526a366dea4fd7d2eab8f3752bf0c28aa0467c5abe80084/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f70686c69622f736d732d6c656e6774682e7376673f6c6f676f3d636f6465636f76)](https://codecov.io/gh/phlib/sms-length)[![Latest Stable Version](https://camo.githubusercontent.com/08b24d26f08f4cc44979c8410482b11c55f6f3c1b45cc3f93c113ae68486e5f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70686c69622f736d732d6c656e6774682e7376673f6c6f676f3d7061636b6167697374)](https://packagist.org/packages/phlib/sms-length)[![Total Downloads](https://camo.githubusercontent.com/ad42ac481afc12fe77d6bf0363233fbf9b10b54574e06a35e13943dafb4976a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70686c69622f736d732d6c656e6774682e7376673f6c6f676f3d7061636b6167697374)](https://packagist.org/packages/phlib/sms-length)[![Licence](https://camo.githubusercontent.com/47e422e2530f5e719d87195cc6a144020c5162fb7d8c51dd5fe827b9bf4a72ba/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70686c69622f736d732d6c656e6774682e737667)](https://camo.githubusercontent.com/47e422e2530f5e719d87195cc6a144020c5162fb7d8c51dd5fe827b9bf4a72ba/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70686c69622f736d732d6c656e6774682e737667)

Calculate SMS GSM 03.38 message encoding and length, and number of concatenated SMS required

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

[](#installation)

```
composer require phlib/sms-length
```

Usage
-----

[](#usage)

Simple string which fits within GSM 03.38 7-bit alphabet:

```
$smsLength = new \Phlib\SmsLength\SmsLength('simple message');
$smsLength->validate(); // Throw exceptions for any validation failures
$smsLength->getSize(); // 14
$smsLength->getEncoding(); // '7-bit'
$smsLength->getMessageCount(); // 1
$smsLength->getUpperBreakpoint(); // 160
```

Message which contains characters forcing switch to using GSM 03.38 UCS-2:

```
$smsLength = new \Phlib\SmsLength\SmsLength('message with • char requiring UCS-2');
$smsLength->validate(); // Throw exceptions for any validation failures
$smsLength->getSize(); // 35
$smsLength->getEncoding(); // 'ucs-2'
$smsLength->getMessageCount(); // 1
$smsLength->getUpperBreakpoint(); // 70
```

Background
----------

[](#background)

In the course of adding an SMS module to our Commercial software, we have found need for the SMS length properties which we've included in this package.

Our third-party SMS gateway provider's API will of course error if the message length exceeds the maximum allowed, and handles the correct concatenation and encoding for the given UTF-8 string.

However we want to be able to inform our users of message size and limits while they're building their SMS campaign (in advance of a live send). Plus we also need to show how many concatenated SMS they will use per contact, and therefore indicate pricing.

The unit tests and inspections made by this package are based on [GSM 03.38 / 3GPP 23.038](https://en.wikipedia.org/wiki/GSM_03.38) for encoding and [GSM 03.40 / 3GPP 23.040](https://en.wikipedia.org/wiki/GSM_03.40) for [concatenated SMS](https://en.wikipedia.org/wiki/Concatenated_SMS). We have also referred to documentation provided by third-party SMS gateway providers such as [MessageBird](https://support.messagebird.com/hc/en-us/articles/208739745-How-long-can-a-text-message-be-)and [Messente](https://messente.com/documentation/tools/sms-length-calculator).

License
-------

[](#license)

This package is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see .

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 95.7% 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 ~638 days

Total

4

Last Release

1423d ago

Major Versions

1.1.0 → 2.0.02021-07-18

PHP version history (2 changes)1.0.0PHP ^5.6|^7

2.0.0PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/135b7ddf9ec91c412e1b18174f81d1ad2bef66e732624195c156717c96b13731?d=identicon)[letssurf](/maintainers/letssurf)

![](https://www.gravatar.com/avatar/10c53cdcfb3a6d299820aecb993521cc1a972baa09fd8f31d2468908cded7e1d?d=identicon)[chrisminett](/maintainers/chrisminett)

---

Top Contributors

[![chrisminett](https://avatars.githubusercontent.com/u/1084019?v=4)](https://github.com/chrisminett "chrisminett (45 commits)")[![SeifertDaniel](https://avatars.githubusercontent.com/u/9882400?v=4)](https://github.com/SeifertDaniel "SeifertDaniel (2 commits)")

---

Tags

messagesmsgsmlengthsize

###  Code Quality

TestsPHPUnit

Code StyleECS

### Embed Badge

![Health badge](/badges/phlib-sms-length/health.svg)

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

###  Alternatives

[php-amqplib/php-amqplib

Formerly videlalvaro/php-amqplib. This library is a pure PHP implementation of the AMQP protocol. It's been tested against RabbitMQ.

4.6k125.3M879](/packages/php-amqplib-php-amqplib)[aws/aws-php-sns-message-validator

Amazon SNS message validation for PHP

21421.5M91](/packages/aws-aws-php-sns-message-validator)[fotografde/cakephp-sms

SMS Plugin for CakePHP

1273.2k](/packages/fotografde-cakephp-sms)

PHPackages © 2026

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