PHPackages                             instasent/sms-counter-php - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. instasent/sms-counter-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

instasent/sms-counter-php
=========================

SMS Counter PHP Class Library which detects encoding of an SMS message text, counts the characters as per the encoding and gives page limit information.

0.5.2(6y ago)491.3M↓16.1%28[3 issues](https://github.com/instasent/sms-counter-php/issues)[4 PRs](https://github.com/instasent/sms-counter-php/pulls)4MITPHPPHP &gt;=5.6.0

Since Jul 18Pushed 2y ago5 watchersCompare

[ Source](https://github.com/instasent/sms-counter-php)[ Packagist](https://packagist.org/packages/instasent/sms-counter-php)[ Docs](http://github.com/instasent/sms-counter-php)[ RSS](/packages/instasent-sms-counter-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (14)Used By (4)

Instasent - SMS Counter for PHP
===============================

[](#instasent---sms-counter-for-php)

Character counter for SMS Messages

[![Build Status](https://camo.githubusercontent.com/9335c8918d3429d19d066d478c0a6167c00cf4e460278a25b8b9ad4d7a5bf0e2/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f696e73746173656e742f736d732d636f756e7465722d7068702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/instasent/sms-counter-php)[![SensioLabsInsight](https://camo.githubusercontent.com/f3187df3b005d2999b3cce95243547f60b5c6e3b0ffaa179f9e5c8c5b3a6ca3a/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f30613266613837612d303238372d343666362d623862352d3831386234346132623966392e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/0a2fa87a-0287-46f6-b8b5-818b44a2b9f9)

Usage
-----

[](#usage)

```
use Instasent\SMSCounter\SMSCounter;

$smsCounter = new SMSCounter();
$smsCounter->count('some-string-to-be-counted');
$smsCounter->countWithShiftTables('some-string-to-be-counted');
```

which returns

```
stdClass Object
(
[encoding]    => GSM_7BIT
[length]      => 25
[per_message] => 160
[remaining]   => 135
[messages]    => 1
)

```

##### UTF16 notice

[](#utf16-notice)

When using unicode chars over U+10000 (mainly emoticons 😎) on messages larger than 70 chars the *remaining* value will actually be the **remaining chars in last message part only**, this is due to how those chars are encoded using two 16bit chars and max part length being an odd number (67)

#### Sanitization

[](#sanitization)

You can sanitize your text to be a valid strict GSM 03.38 charset

```
use Instasent\SMSCounter\SMSCounter;

$smsCounter = new SMSCounter();
$smsCounter->sanitizeToGSM('dadáó'); //return dadao
```

#### National Language Shift Tables

[](#national-language-shift-tables)

Starting release 8 of GSM 03.38 some additional charsets are allowed. This is the list of such National Language Shift Tables currently supported

- [Turkish](https://en.wikipedia.org/wiki/GSM_03.38#Turkish_language_(Latin_script))
- [Spanish](https://en.wikipedia.org/wiki/GSM_03.38#Spanish_language_(Latin_script))
- [Portuguese](https://en.wikipedia.org/wiki/GSM_03.38#Portuguese_language_(Latin_script))

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

[](#installation)

`sms-counter-php` is available via [composer](http://getcomposer.org) on [packagist](https://packagist.org/packages/instasent/sms-counter-php).

```
{
    "require": {
       "instasent/sms-counter-php": "^0.4"
    }
}
```

License
-------

[](#license)

SMS Counter (PHP) is released under the [MIT License](LICENSE-MIT.md)

### Mentions

[](#mentions)

- Original idea : [danxexe/sms-counter](https://github.com/danxexe/sms-counter)
- Fork Idea from: [acpmasquerade/sms-counter-php](https://github.com/acpmasquerade/sms-counter-php)

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity54

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 51.1% 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 ~129 days

Recently: every ~189 days

Total

12

Last Release

2539d ago

PHP version history (3 changes)v0.1.0PHP &gt;=5.3.0

v0.2.0PHP &gt;=5.4.0

v0.4.0PHP &gt;=5.6.0

### Community

Maintainers

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

---

Top Contributors

[![luishdez](https://avatars.githubusercontent.com/u/38347?v=4)](https://github.com/luishdez "luishdez (23 commits)")[![juliangut](https://avatars.githubusercontent.com/u/1104131?v=4)](https://github.com/juliangut "juliangut (13 commits)")[![markitosgv](https://avatars.githubusercontent.com/u/1706470?v=4)](https://github.com/markitosgv "markitosgv (8 commits)")[![z38](https://avatars.githubusercontent.com/u/3948085?v=4)](https://github.com/z38 "z38 (1 commits)")

---

Tags

gsmphpsms-counterunicodesmsmobilecountergsm

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/instasent-sms-counter-php/health.svg)

```
[![Health](https://phpackages.com/badges/instasent-sms-counter-php/health.svg)](https://phpackages.com/packages/instasent-sms-counter-php)
```

###  Alternatives

[mobiledetect/mobiledetectlib

Mobile\_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.

10.7k159.4M431](/packages/mobiledetect-mobiledetectlib)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[jenssegers/agent

Desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

4.8k67.8M440](/packages/jenssegers-agent)[php-smpp/php-smpp

PHP-based SMPP client lib

234197.5k8](/packages/php-smpp-php-smpp)[alexandr-mironov/php-smpp

PHP SMPP client lib, fork of onlinecity/php-smpp

4864.3k](/packages/alexandr-mironov-php-smpp)[benmorel/gsm-charset-converter

Converts GSM 03.38 strings to and from UTF-8

16423.5k](/packages/benmorel-gsm-charset-converter)

PHPackages © 2026

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