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

ActiveLibrary

adevpmftc/msisdn-ph
===================

An MSISDN identification and cleaner library for Philippine telco subscribers

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

Since Jun 12Pushed 11mo agoCompare

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

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

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

[](#msisdnph---php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/000d7aab87cc8c6bbc81d6832924392d086bd1f5f4001ffbf1b434f15621e5a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61646576706d6674632f6d736973646e2d70682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/adevpmftc/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/1de45d3b40f9bb80dfab6e25dcadf0378ff17190af1e4871be3620f97988535c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61646576706d6674632f6d736973646e2d70682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/adevpmftc/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 adevpmftc/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 AdevPmftc\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://coreproc.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

Maturity33

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

3

Last Release

332d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

1.2.0PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/111575d28709d94013bbe091079787efe1c49c874d72d050f5d9ad002f377bb0?d=identicon)[AdevPmftc](/maintainers/AdevPmftc)

---

Top Contributors

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

---

Tags

sunmsisdnsmartmsisdn philippinesglobemobile number

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[coreproc/msisdn-ph

An MSISDN identification and cleaner library for Philippine telco subscribers

2828.1k4](/packages/coreproc-msisdn-ph)[infobip/infobip-api-php-client

PHP library for consuming Infobip's API

921.8M10](/packages/infobip-infobip-api-php-client)[spatie/sun

Get information on the position of the sun

73165.5k3](/packages/spatie-sun)[dietercoopman/smart

This packages enables the ability to serve file streams in a smart way

2387.5k](/packages/dietercoopman-smart)[jlapp/smart-seeder

Smart Seeder adds the same methology to seeding that is currently used with migrations in order to let you seed in batches, seed to production databases or other environments, and to rerun seeds without wiping out your data.

1903.1k](/packages/jlapp-smart-seeder)[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)

PHPackages © 2026

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