reusable/phone-checker
Composer 安装命令:
composer require reusable/phone-checker
包简介
A reusable phone number validation package for Laravel.
README 文档
README
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 reusable/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 Reusable\PhoneChecker\Facades\PhoneChecker; // Check if a number is valid for Myanmar PhoneChecker::check('09421234567', 'MM'); // true
Via Dependency Injection
use Reusable\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 Reusable\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
reusable/phone-checker 适用场景与选型建议
reusable/phone-checker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 reusable/phone-checker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 reusable/phone-checker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-03