PHPackages                             giggsey/libphonenumber-for-php-lite - 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. giggsey/libphonenumber-for-php-lite

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

giggsey/libphonenumber-for-php-lite
===================================

A lite version of giggsey/libphonenumber-for-php, which is a PHP Port of Google's libphonenumber

9.0.26(2mo ago)8912.9M—2.9%720Apache-2.0PHPPHP ^8.1CI passing

Since Nov 9Pushed 1w ago3 watchersCompare

[ Source](https://github.com/giggsey/libphonenumber-for-php-lite)[ Packagist](https://packagist.org/packages/giggsey/libphonenumber-for-php-lite)[ Docs](https://github.com/giggsey/libphonenumber-for-php-lite)[ RSS](/packages/giggsey-libphonenumber-for-php-lite/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (28)Versions (85)Used By (20)

libphonenumber for PHP (Lite) [![Build Status](https://github.com/giggsey/libphonenumber-for-php-lite/workflows/Tests/badge.svg)](https://github.com/giggsey/libphonenumber-for-php-lite/actions?query=workflow%3A%22Tests%22) [![codecov](https://camo.githubusercontent.com/35b88f6d2cf0c9e7ea409f56992d2a9316bfebdc45455cd3c0e35e76d03aca04/68747470733a2f2f636f6465636f762e696f2f67682f676967677365792f6c696270686f6e656e756d6265722d666f722d7068702d6c6974652f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d53305456325441584f51)](https://codecov.io/gh/giggsey/libphonenumber-for-php-lite) [![Mutation testing badge](https://camo.githubusercontent.com/0fe313c5cd8c8302953ee3b1a038e1b9f5ea2dca5a25ec8f80895c659cec864b/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742d7371756172652675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246676967677365792532466c696270686f6e656e756d6265722d666f722d7068702d6c6974652532466d61696e)](https://dashboard.stryker-mutator.io/reports/github.com/giggsey/libphonenumber-for-php-lite/main)
====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#libphonenumber-for-php-lite---)

[![Total Downloads](https://camo.githubusercontent.com/e0b19d81e94a1064013da795500dd29c6a8e803d03eccdd7f0472f58a9abaa75/68747470733a2f2f706f7365722e707567782e6f72672f676967677365792f6c696270686f6e656e756d6265722d666f722d7068702d6c6974652f646f776e6c6f6164733f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/giggsey/libphonenumber-for-php-lite)[![Downloads per month](https://camo.githubusercontent.com/c862a0628af17f29d1c62535cc34e0b20c6092fb7c6613e1a0baddf62f054c09/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f676967677365792f6c696270686f6e656e756d6265722d666f722d7068702d6c6974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/giggsey/libphonenumber-for-php-lite)[![Latest Stable Version](https://camo.githubusercontent.com/7f03b650517c442b95bfcc1833943a6b841b77dfa90f15f44f45390167bf54ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f676967677365792f6c696270686f6e656e756d6265722d666f722d7068702d6c6974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/giggsey/libphonenumber-for-php-lite)[![License](https://camo.githubusercontent.com/25524f6af11190841a6f92c8df1c414285cbf089df2feadb14230c96d872d4f1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d7265642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/giggsey/libphonenumber-for-php-lite)

What is it?
-----------

[](#what-is-it)

A PHP library for parsing, formatting, storing and validating international phone numbers. This library is based on Google's [libphonenumber](https://github.com/google/libphonenumber).

This is a lite version that only includes the core Phone Number Utils. To make full use of the library, including geolocation, carrier information and short number info, use [giggsey/libphonenumber-for-php](https://github.com/giggsey/libphonenumber-for-php)

- [Installation](#installation)
- [Documentation](#documentation)
- [Highlights of functionality](#highlights-of-functionality)
    - [Versioning](#versioning)
    - [Quick Examples](#quick-examples)
- [FAQ](#faq)
    - [Problems with Invalid Numbers?](#problems-with-invalid-numbers)
- [Generating data](#generating-data)

Installation
------------

[](#installation)

PHP versions 8.1 and above are supported.

The PECL [mbstring](http://php.net/mbstring) extension is required.

It is recommended to use [composer](https://getcomposer.org) to install the library.

```
composer require giggsey/libphonenumber-for-php-lite
```

You can also use any other [PSR-4](http://www.php-fig.org/psr/psr-4/) compliant autoloader.

### PHP Version Policy

[](#php-version-policy)

This library will be updated to use [supported versions of PHP](https://www.php.net/supported-versions.php) only.

Documentation
-------------

[](#documentation)

- [PhoneNumber Util](docs/PhoneNumberUtil.md)

Highlights of functionality
===========================

[](#highlights-of-functionality)

- Parsing/formatting/validating phone numbers for all countries/regions of the world.
- `getNumberType` - gets the type of the number based on the number itself; able to distinguish Fixed-line, Mobile, Toll-free, Premium Rate, Shared Cost, VoIP and Personal Numbers (whenever feasible).
- `isNumberMatch` - gets a confidence level on whether two numbers could be the same.
- `getExampleNumber`/`getExampleNumberByType` - provides valid example numbers for all countries/regions, with the option of specifying which type of example phone number is needed.
- `isValidNumber` - full validation of a phone number for a region using length and prefix information.

Versioning
----------

[](#versioning)

This library will try to follow the same version numbers as Google. There could be additional releases where needed to fix critical issues that can not wait until the next release from Google.

This does mean that this project may not follow [Semantic Versioning](http://semver.org/), but instead Google's version policy. As a result, jumps in major versions may not actually contain any backwards incompatible changes. Please read the release notes for such releases.

Google try to release their versions according to Semantic Versioning, as laid out of in their [Versioning Guide](https://github.com/google/libphonenumber#versioning-and-announcements).

Quick Examples
--------------

[](#quick-examples)

Let's say you have a string representing a phone number from Switzerland. This is how you parse/normalize it into a PhoneNumber object:

```
$swissNumberStr = "044 668 18 00";
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
try {
    $swissNumberProto = $phoneUtil->parse($swissNumberStr, "CH");
    var_dump($swissNumberProto);
} catch (\libphonenumber\NumberParseException $e) {
    var_dump($e);
}
```

At this point, swissNumberProto contains:

```
class libphonenumber\PhoneNumber#9 (7) {
 private $countryCode =>
  int(41)
 private $nationalNumber =>
  double(446681800)
 private $extension =>
  NULL
 private $italianLeadingZero =>
  NULL
 private $rawInput =>
  NULL
 private $countryCodeSource =>
  NULL
 private $preferredDomesticCarrierCode =>
  NULL
}

```

Now let us validate whether the number is valid:

```
$isValid = $phoneUtil->isValidNumber($swissNumberProto);
var_dump($isValid); // true
```

There are a few formats supported by the formatting method, as illustrated below:

```
// Produces "+41446681800"
echo $phoneUtil->format($swissNumberProto, \libphonenumber\PhoneNumberFormat::E164);

// Produces "044 668 18 00"
echo $phoneUtil->format($swissNumberProto, \libphonenumber\PhoneNumberFormat::NATIONAL);

// Produces "+41 44 668 18 00"
echo $phoneUtil->format($swissNumberProto, \libphonenumber\PhoneNumberFormat::INTERNATIONAL);
```

You could also choose to format the number in the way it is dialled from another country:

```
// Produces "011 41 44 668 1800", the number when it is dialled in the United States.
echo $phoneUtil->formatOutOfCountryCallingNumber($swissNumberProto, "US");

// Produces "00 41 44 668 18 00", the number when it is dialled in Great Britain.
echo $phoneUtil->formatOutOfCountryCallingNumber($swissNumberProto, "GB");
```

FAQ
---

[](#faq)

#### Problems with Invalid Numbers?

[](#problems-with-invalid-numbers)

This library uses phone number metadata from Google's [libphonenumber](https://github.com/google/libphonenumber). If this library is working as intended, it should provide the same result as the Java version of Google's project.

If you believe that a phone number is returning an incorrect result, first test it with [libphonenumber](https://github.com/google/libphonenumber) via their [Online Demo](https://libphonenumber.appspot.com/). If that returns the same result as this project, and you feel it is in error, raise it as an Issue with the libphonenumber project.

If Google's [Online Demo](https://libphonenumber.appspot.com/) gives a different result to the [libphonenumber-for-php demo](http://giggsey.com/libphonenumber/), then please raise an Issue on the [giggsey/libphonenumber-for-php](https://github.com/giggsey/libphonenumber-for-php) project.

If [giggsey/libphonenumber-for-php](https://github.com/giggsey/libphonenumber-for-php) differs from this library, please raise an issue here instead.

Generating data
---------------

[](#generating-data)

Generating the data is not normally needed, as this repository will generally always have the up to date metadata.

To compile the data, run the composer script 'build'

```
composer run build
```

This build process clones the [libphonenumber](https://github.com/google/libphonenumber) project at the version specified in [METADATA-VERSION.php](METADATA-VERSION.php).

###  Health Score

68

—

FairBetter than 100% of packages

Maintenance93

Actively maintained with recent releases

Popularity61

Solid adoption and visibility

Community38

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 84.5% 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 ~14 days

Total

83

Last Release

67d ago

Major Versions

8.13.55 → 9.0.02025-03-20

PHP version history (2 changes)8.13.0PHP ^8.0

8.13.36PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/ecb77e06c21edac6b84d9428a23c632eb08a96f897de0bde76dd467846ded35a?d=identicon)[giggsey](/maintainers/giggsey)

---

Top Contributors

[![giggsey](https://avatars.githubusercontent.com/u/305730?v=4)](https://github.com/giggsey "giggsey (1043 commits)")[![davideme](https://avatars.githubusercontent.com/u/858090?v=4)](https://github.com/davideme "davideme (71 commits)")[![justjkk](https://avatars.githubusercontent.com/u/192893?v=4)](https://github.com/justjkk "justjkk (22 commits)")[![ajayrungta](https://avatars.githubusercontent.com/u/394210?v=4)](https://github.com/ajayrungta "ajayrungta (22 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (13 commits)")[![Nephele](https://avatars.githubusercontent.com/u/3705856?v=4)](https://github.com/Nephele "Nephele (12 commits)")[![joshuagiggxon](https://avatars.githubusercontent.com/u/35339413?v=4)](https://github.com/joshuagiggxon "joshuagiggxon (5 commits)")[![BenMorel](https://avatars.githubusercontent.com/u/1952838?v=4)](https://github.com/BenMorel "BenMorel (4 commits)")[![BenjaminHoegh](https://avatars.githubusercontent.com/u/22152591?v=4)](https://github.com/BenjaminHoegh "BenjaminHoegh (4 commits)")[![zoloft](https://avatars.githubusercontent.com/u/2939780?v=4)](https://github.com/zoloft "zoloft (3 commits)")[![cafferata](https://avatars.githubusercontent.com/u/1150425?v=4)](https://github.com/cafferata "cafferata (3 commits)")[![garak](https://avatars.githubusercontent.com/u/179866?v=4)](https://github.com/garak "garak (3 commits)")[![tom-1bg](https://avatars.githubusercontent.com/u/11245840?v=4)](https://github.com/tom-1bg "tom-1bg (3 commits)")[![abhinavlal](https://avatars.githubusercontent.com/u/445119?v=4)](https://github.com/abhinavlal "abhinavlal (2 commits)")[![iGusev](https://avatars.githubusercontent.com/u/1555767?v=4)](https://github.com/iGusev "iGusev (2 commits)")[![captn3m0](https://avatars.githubusercontent.com/u/584253?v=4)](https://github.com/captn3m0 "captn3m0 (2 commits)")[![boekkooi](https://avatars.githubusercontent.com/u/399895?v=4)](https://github.com/boekkooi "boekkooi (2 commits)")[![antonkomarev](https://avatars.githubusercontent.com/u/1849174?v=4)](https://github.com/antonkomarev "antonkomarev (2 commits)")[![omahm](https://avatars.githubusercontent.com/u/1013025?v=4)](https://github.com/omahm "omahm (2 commits)")[![Propaganistas](https://avatars.githubusercontent.com/u/6680176?v=4)](https://github.com/Propaganistas "Propaganistas (2 commits)")

---

Tags

hacktoberfestlibphonenumberphone-numberphpvalidationgeocodinggeolocationlibphonenumbermobilephonenumber

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/giggsey-libphonenumber-for-php-lite/health.svg)

```
[![Health](https://phpackages.com/badges/giggsey-libphonenumber-for-php-lite/health.svg)](https://phpackages.com/packages/giggsey-libphonenumber-for-php-lite)
```

###  Alternatives

[giggsey/libphonenumber-for-php

A library for parsing, formatting, storing and validating international phone numbers, a PHP Port of Google's libphonenumber.

5.0k148.7M416](/packages/giggsey-libphonenumber-for-php)[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[composer/semver

Version comparison library that offers utilities, version constraint parsing and validation.

3.3k489.6M672](/packages/composer-semver)[opis/json-schema

Json Schema Validator for PHP

64736.9M186](/packages/opis-json-schema)[workerman/validation

The most awesome validation engine ever created for PHP. Respect/Validation 汉化版本

2334.1k9](/packages/workerman-validation)

PHPackages © 2026

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