定制 alfan06/msisdn-ph 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alfan06/msisdn-ph

Composer 安装命令:

composer require alfan06/msisdn-ph

包简介

An MSISDN identification and cleaner library for Philippine telco subscribers

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Easily validate and manipulate Philippine mobile numbers.

Table of contents

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

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

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

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

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

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

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

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.

License

The MIT License (MIT). Please see License File for more information.

alfan06/msisdn-ph 适用场景与选型建议

alfan06/msisdn-ph 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「smart」 「msisdn」 「msisdn philippines」 「globe」 「sun」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 alfan06/msisdn-ph 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 alfan06/msisdn-ph 我们能提供哪些服务?
定制开发 / 二次开发

基于 alfan06/msisdn-ph 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 32
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-09