Download the PHP package gordonsarah/tz-phone without Composer
On this page you can find all versions of the php package gordonsarah/tz-phone. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gordonsarah/tz-phone
More information about gordonsarah/tz-phone
Files in gordonsarah/tz-phone
Package tz-phone
Short Description Validate, normalize, and identify Tanzanian mobile numbers by telecom operator (Vodacom, Airtel, Yas / Mixx by Yas, Halotel, TTCL).
License MIT
Homepage https://github.com/SarahGordon895/tz-phone
Informations about the package tz-phone
Tanzania Phone Validator
A PHP package (with optional Laravel extras) that validates, normalizes, and identifies Tanzanian mobile numbers using the TCRA National Numbering Plan.
Sponsored by TechMorah.
Features
- Validate Tanzanian mobile numbers (
isValid()), including Laraveltz_phoneandtz_phone:vodacom - Normalize messy input (
0754 123 456,255754123456,+255754123456) into E.164 and local form - Identify the telecom company from the prefix: Vodacom, Airtel, Yas (Mixx by Yas / Tigo / Zantel), Halotel, TTCL, Smile, and others
- Identify the mobile-money wallet: M-Pesa, Airtel Money, Mixx by Yas, HaloPesa, T-Pesa
- Format numbers as E.164 (
+255754123456), local (0754123456), and international (+255 754 123 456) - Manage prefixes in the database — add, update, or remove codes when TCRA assigns new ranges, without changing package code
- Laravel extras: validation rule, Artisan commands, Eloquent models, config publish, auto-discovery
- Plain PHP works without Laravel; optional SQLite store for the same prefix tables
- MIT License
It maps the prefix to the original network:
| Operator | Company | Mobile money | Prefixes | Status |
|---|---|---|---|---|
| Vodacom | Vodacom Tanzania PLC | M-Pesa | 074, 075, 076, 079 | operational |
| Airtel | Airtel Tanzania PLC | Airtel Money | 068, 069, 078 | operational |
| Yas (Tigo / Mixx) | Honora Tanzania PLC | Mixx by Yas | 065, 067, 071, 077 | operational (077 former Zantel) |
| Halotel | Viettel Tanzania PLC | HaloPesa | 061, 062 | 062 not operational |
| TTCL | Tanzania Telecommunications Corporation | T-Pesa | 073 | operational |
| Smile | Smile Communications Tanzania Limited | — | 066 | reserved (still circulating) |
| Amotel | Mkulima African Telecommunication Company Limited | — | 063 | reserved |
| CooTel | Wiafrica Tanzania Limited | — | 064 | reserved |
| MO Mobile | MO Mobile Holding Limited | — | 072 | reserved |
070 is reserved by TCRA and is not assigned until you add it in the database. Prefixes live in data (config or database), not hardcoded if statements.
PHP packages are published on Packagist, not pub.dev. pub.dev is the registry for Dart/Flutter.
Installation
Laravel 10+ will auto-discover the service provider. Then create the prefix tables and seed TCRA defaults:
After that, prefixes are read from the database. Adding a new TCRA code is a row change, not a code change.
Usage
Accepted input shapes:
0754123456754123456255754123456+255754123456- spaced / dashed variants such as
255 754 123 456
Helper:
Identify Mixx by Yas, Vodacom, Airtel, Halotel, TTCL
Manage prefixes from the database
Laravel uses your app database (MySQL, PostgreSQL, or SQLite). Tables:
tz_phone_operators— telecom company / brand / wallettz_phone_prefixes—075→ Vodacom,071→ Yas, and so on
Artisan:
Eloquent (Filament, Nova, or your own admin):
Plain PHP with SQLite (no Laravel):
Laravel validation
String rule (after the service provider is loaded):
Facade:
Bootstrap demo
Open http://127.0.0.1:8080 to try numbers against the live registry.
Caveats
- Prefix lookup identifies the original assigned network, not necessarily the current operator after mobile number portability.
062is assigned to Halotel but listed not operational in TCRA 2025.066/063/064/072are historical or reserved ranges that still identify a company;isValid(true)rejects them.- This package covers mobile NDCs (
06X/07X), not fixed-line geographic numbers.
Testing
Changelog
Please see CHANGELOG.
Security
Please review SECURITY for how to report vulnerabilities.
Credits
- Sarah Gordon · GordonSarah
- Sponsored by TechMorah
- Numbering data from the Tanzania Communications Regulatory Authority
License
The MIT License (MIT). Please see LICENSE.