PHPackages                             xudongyss/phonenumber - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. xudongyss/phonenumber

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

xudongyss/phonenumber
=====================

1.0.4(1y ago)011PHP

Since Nov 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/xudongyss/phonenumber)[ Packagist](https://packagist.org/packages/xudongyss/phonenumber)[ RSS](/packages/xudongyss-phonenumber/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

电话号码
====

[](#电话号码)

安装
--

[](#安装)

```
composer require xudongyss/phonenumber

```

快速使用
----

[](#快速使用)

### 验证手机号

[](#验证手机号)

国际区号详见：

```
require_once 'vendor/autoload.php';

use phonenumber\PhoneNumber;

/* 国际区号：86：中国，856：香港 */
$countryCallingCode = '86';
$phoneNumber = '';
$phoneNumber = PhoneNumber::isMobile($countryCallingCode, $phoneNumber);
// false or libphonenumber\PhoneNumber Object
var_dump($phoneNumber);
```

### 验证电话号码（含手机号和固话）

[](#验证电话号码含手机号和固话)

```
$phoneNumber = PhoneNumber::isPhoneNumber($countryCallingCode, $phoneNumber);
// false or libphonenumber\PhoneNumber Object
var_dump($phoneNumber);
```

### 获取号码

[](#获取号码)

不存在空格，不存在区号的。例如：假如提供验证的号码为：+86 135 0000 0001，则此方法返回：13500000001

```
/* $phoneNumber 手机号码对象或者 电话号码对象 */
PhoneNumber::getNationalNumber($phoneNumber);
```

libphonenumber\\PhoneNumber Object
----------------------------------

[](#libphonenumberphonenumber-object)

FunctionValuegetCountryCode()86getNationalNumber()13500000001getExtension()getCountryCodeSource()FROM\_DEFAULT\_COUNTRYisItalianLeadingZero()falsegetRawInput()173 0000 0000

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

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

Total

5

Last Release

598d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0f89328b21f1a0ff093d7c8df84f784af3cdd9c81c016362a65eb98dac4634fe?d=identicon)[xudongyss](/maintainers/xudongyss)

---

Top Contributors

[![xudongyss](https://avatars.githubusercontent.com/u/44386082?v=4)](https://github.com/xudongyss "xudongyss (10 commits)")

### Embed Badge

![Health badge](/badges/xudongyss-phonenumber/health.svg)

```
[![Health](https://phpackages.com/badges/xudongyss-phonenumber/health.svg)](https://phpackages.com/packages/xudongyss-phonenumber)
```

###  Alternatives

[ronanguilloux/isocodes

PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Book and Music Industries, Phone numbers &amp; Zipcodes for many countries

8013.3M23](/packages/ronanguilloux-isocodes)[borales/yii2-phone-input

Yii2 International telephone numbers - Asset Bundle, Behavior, Validator, Widget

1341.6M6](/packages/borales-yii2-phone-input)[ipub/phone

Phone helper &amp; validator for Nette Framework

1285.3k6](/packages/ipub-phone)[yii2mod/yii2-validators

Collection of useful validators for Yii Framework 2.0

1816.8k](/packages/yii2mod-yii2-validators)

PHPackages © 2026

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