PHPackages                             alfan06/msisdn-ph - 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. alfan06/msisdn-ph

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

alfan06/msisdn-ph
=================

An MSISDN identification and cleaner library for Philippine telco subscribers

1.3.0(11mo ago)00MITPHPPHP &gt;=5.4CI passing

Since Jun 9Pushed 11mo agoCompare

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

READMEChangelog (3)Dependencies (2)Versions (5)Used By (0)

MsisdnPH - PHP
==============

[](#msisdnph---php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ce4e9dbff0a93b46478c44ee72f2337a7109f520e2f7c3a05cb3bb4be6cddd67/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6166616e30362f6d736973646e2d70682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/afan06/msisdn-ph)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/479a1c846d0ca5b0ffb4b9b64a7705ebe956bd130e8de513e06be6126b0c77c7/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f436f726550726f632f6d736973646e2d70682d7068702f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/CoreProc/msisdn-ph-php)[![Coverage Status](https://camo.githubusercontent.com/e3aa1393000ee9356fba14d9ae6eed60f7d667ed16574c82f260a0e94063995e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f436f726550726f632f6d736973646e2d70682d7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/CoreProc/msisdn-ph-php/code-structure)[![Quality Score](https://camo.githubusercontent.com/24f432259c0e7a778e5c80f501359762ce76ee0f44f607f615e4d935bf676866/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f436f726550726f632f6d736973646e2d70682d7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/CoreProc/msisdn-ph-php)[![Total Downloads](https://camo.githubusercontent.com/2b85ceaf16d202bf9c7e779e583e355b070e1832708bea7ae63170464598f9f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6166616e30362f6d736973646e2d70682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/afan06/msisdn-ph)

Easily validate and manipulate Philippine mobile numbers.

Table of contents
-----------------

[](#table-of-contents)

- [Install](#install)
- [Usage](#usage)
    - [Validate the mobile number](#validate-the-mobile-number)
    - [Instantiate an MSISDN object](#instantiate-an-msisdn-object)
    - [Return a standardized format of your mobile number](#return-a-standardized-format-of-your-mobile-number)
    - [Get the telco operator of a mobile number](#get-the-telco-operator-of-a-mobile-number)
    - [Get the prefix of a mobile number](#get-the-prefix-of-a-mobile-number)
    - [Validating mobile numbers using Laravel 5.1](#validating-mobile-numbers-using-laravel-51)
- [Credits](#credits)
- [License](#license)

Install
-------

[](#install)

Run the following command at the root of your project (assuming you have Composer and a composer.json file already)

```
composer require afan06/msisdn-ph "^1.0"
```

Usage
-----

[](#usage)

### Validate the mobile number

[](#validate-the-mobile-number)

```
$mobileNumber = '09171231234';

if (Msisdn::validate($mobileNumber)) {
    echo 'Valid mobile number';
} else {
    echo 'Invalid mobile number';
}
```

The `validate` method cleans the given mobile number and validates it so even if the mobile number is malformed or has other characters within it, it will still return true as long as the number is really valid:

```
$validMobileNumber = '+639171231234';
$validMobileNumber = '+63-917-123-1234';
$validMobileNumber = '0917-123-1234';
$validMobileNumber = '0917.123.1234';
$validMobileNumber = '63 917 123 12 34 ';
```

### Instantiate an MSISDN object

[](#instantiate-an-msisdn-object)

You can instantiate an MSISDN object and get a standardized format of your mobile number and even get the telco attached to the mobile number using this object.

```
$mobileNumber = '09171231234';

$msisdn = new Msisdn($mobileNumber);
```

The MSISDN object will throw an `InvalidMsisdnException` if you give it an invalid mobile number, so it's best to either catch the exception OR validate it before creating an MSISDN object.

```
$invalidMobileNumber = '0917-123-123';

try {
   $msisdn = new Msisdn($invalidMobileNumber);
} catch (InvalidMsisdnException $e) {
   echo 'The number is invalid';
   return;
}
```

OR

```
$invalidMobileNumber = '0917-123-123';

if (Msisdn::validate($invalidMobileNumber)) {
    $msisdn = new Msisdn($invalidMobileNumber);
} else {
   echo 'Invalid mobile number';
   return;
}
```

### Return a standardized format of your mobile number

[](#return-a-standardized-format-of-your-mobile-number)

When you've instantiated an `Msisdn` object, you can return the mobile number in any format you want.

```
$mobileNumber = '09171231234';

$msisdn = new Msisdn($mobileNumber);

echo $msisdn->get(); // will return 09171231234

echo $msisdn->get(true); // will return +639171231234

echo $msisdn->get(false, '-'); // will return 0917-123-1234

echo $msisdn->get(true, '-'); // will return +63-917-123-1234

echo $msisdn->get(true, '.'); // will return +63.917.123.1234
```

### Get the telco operator of a mobile number

[](#get-the-telco-operator-of-a-mobile-number)

You can also get the telco operator of the given mobile number - this is based on the included prefixes we have gathered from the telcos.

We cannot guarantee that this list is updated so use with a grain of salt.

If you want to add to the prefixes, you can find the list inside the `src/prefixes` directory.

```
$mobileNumber = '09171231234';

$msisdn = new Msisdn($mobileNumber);

echo $msisdn->getOperator(); // will return Globe
```

### Get the prefix of a mobile number

[](#get-the-prefix-of-a-mobile-number)

You might just want to get the prefix of a mobile number.

```
$mobileNumber = '09171231234';

$msisdn = new Msisdn($mobileNumber);

echo $msisdn->getPrefix(); // will return 917
```

### Validating mobile numbers using Laravel 5.1

[](#validating-mobile-numbers-using-laravel-51)

You can easily integrate this into Laravel's validator class by adding the line below to the default `AppServiceProvider` located in the `app/Providers` directory.

Inside the `boot()` method, add the following line:

```
Validator::extend('msisdn', function ($attribute, $value, $parameters) {
    return Alfan06\MsisdnPh\Msisdn::validate($value);
});
```

Credits
-------

[](#credits)

- [Chris Bautista](https://github.com/chrisbjr)
- [All Contributors](../../contributors)

About CoreProc
--------------

[](#about-coreproc)

CoreProc is a software development company that provides software development services to startups, digital/ad agencies, and enterprises.

Learn more about us on our [website](https://afan06.com).

License
-------

[](#license)

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

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance52

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

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

Total

4

Last Release

337d ago

PHP version history (2 changes)1.2.0PHP &gt;=5.4

1.0PHP &gt;=5.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/994a22c91a36fee3c57db76ecddab0ab8ea4f15b106714cf2ea77b0d00907828?d=identicon)[alfan06](/maintainers/alfan06)

---

Top Contributors

[![alfan06](https://avatars.githubusercontent.com/u/56281741?v=4)](https://github.com/alfan06 "alfan06 (15 commits)")

---

Tags

sunmsisdnsmartmsisdn philippinesglobe

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alfan06-msisdn-ph/health.svg)

```
[![Health](https://phpackages.com/badges/alfan06-msisdn-ph/health.svg)](https://phpackages.com/packages/alfan06-msisdn-ph)
```

###  Alternatives

[coreproc/msisdn-ph

An MSISDN identification and cleaner library for Philippine telco subscribers

2828.1k4](/packages/coreproc-msisdn-ph)[spatie/sun

Get information on the position of the sun

73165.5k3](/packages/spatie-sun)[sun/country

Sun Country is the package that helps you to get the country name &amp; dialing code by the country ISO 3166-1 Alpha-2 code.

1016.5k](/packages/sun-country)[vaersaagod/seomate

SEO, mate! It's important.

4341.6k2](/packages/vaersaagod-seomate)[gkermer/nova-text-auto-complete

A Laravel Nova text autocomplete field.

22115.5k1](/packages/gkermer-nova-text-auto-complete)[chinayin/ip2region-core

Ip2region (2.0 - xdb) is a offline IP address manager framework and locator with ten microsecond searching performance. xdb engine implementation for many programming languages

2218.3k2](/packages/chinayin-ip2region-core)

PHPackages © 2026

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