moetain/myanmar-phone-checker 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

moetain/myanmar-phone-checker

Composer 安装命令:

composer require moetain/myanmar-phone-checker

包简介

A reusable phone number validation package for Laravel.

README 文档

README

Latest Version on Packagist Total Downloads License Tests

A sophisticated, highly configurable phone number validation and identification package for Laravel. Designed for precision, it handles sanitization, validation, and advanced metadata extraction like operator and country detection.

🚀 Features

  • Global Validation: Precision rules for Myanmar (MM), Thailand (TH), Japan (JP), United States (US), China (CN), Vietnam (VN), and United Kingdom (GB).
  • Operator Detection: Specialized detection for Myanmar carriers (MPT, ATOM, U9/Ooredoo, Mytel).
  • Country Identification: Automatically resolve the country from any given phone number.
  • Smart Sanitization: Robustly handles common formatting characters (-, , ( )) before processing.
  • E.164 & Local Formats: Supports both international and national dialing formats.
  • Pest Powered: Ships with a comprehensive Pest test suite.

📦 Installation

Install the package via composer:

composer require moetain/myanmar-phone-checker

The service provider will automatically register itself.

⚙️ Configuration

Publish the config file to customize default behavior and add new country rules:

php artisan vendor:publish --tag="phone-checker-config"

The configuration file allows you to:

  • Change the default country.
  • Add or modify country rules (regex, prefixes, lengths).
  • Define operators with names and logos for any country.

🛠 Usage

Basic Validation

The package provides a convenient PhoneChecker facade and is also available via dependency injection.

Via Facade

use Moetain\PhoneChecker\Facades\PhoneChecker;

// Check if a number is valid for Myanmar
PhoneChecker::check('09421234567', 'MM'); // true

Via Dependency Injection

use Moetain\PhoneChecker\PhoneChecker;

public function store(Request $request, PhoneChecker $checker)
{
    if ($checker->check($request->phone, 'MM')) {
        // ...
    }
}

Laravel Validation Rule

The package includes a custom validation rule for seamless integration with Laravel's validation system.

use Moetain\PhoneChecker\Rules\Phone;

$request->validate([
    'phone' => ['required', new Phone('MM')],
]);

Country Detection

Resolve the country of origin from a raw phone string.

// Detects country automatically
$country = PhoneChecker::getCountry('+66 912 345 678'); // 'TH'
$country = PhoneChecker::getCountry('+1-123-456-7890'); // 'US'

Operator Information (Myanmar Specialized)

Identify the carrier and retrieve operator metadata.

// Get operator key (e.g., 'MPT', 'ATOM', 'U9', 'Mytel')
$operator = PhoneChecker::getOperator('09951234567'); // 'U9'

// Get display-friendly operator name
$operatorName = PhoneChecker::getOperatorName('09951234567'); // 'Ooredoo / U9'

// Get operator logo URL
$logo = PhoneChecker::getOperatorLogo('09951234567'); // 'https://.../u9-logo.png'

Country Metadata

Retrieve details about the detected or specified country.

// Get country flag (emoji)
$flag = PhoneChecker::getFlag('MM'); // '🇲🇲'

// Get full country name
$name = PhoneChecker::getName('MM'); // 'Myanmar'

// Get international dialing code
$code = PhoneChecker::getCountryCode('MM'); // '+95'

Comprehensive Information

Get all available information about a phone number in a single call.

$info = PhoneChecker::getInfo('09421234567');

/*
Returns:
[
    'phone'    => '09421234567',
    'country'  => 'Myanmar',
    'iso'      => 'MM',
    'flag'     => '🇲🇲',
    'code'     => '+95',
    'operator' => 'MPT',
    'logo'     => 'https://...',
    'is_valid' => true,
]
*/

🧪 Testing

The package is tested heavily using Pest. To run the tests, execute:

composer test

📄 License

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

myanmar-phone-checker

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固