PHPackages                             juanparati/mobile-numbers - 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. juanparati/mobile-numbers

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

juanparati/mobile-numbers
=========================

An international mobile number validator

2.0.1(2mo ago)04.3k↓50%1GPL-3.0-or-laterPHPPHP &gt;=8.1CI passing

Since Nov 9Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/juanparati/mobilenumbers)[ Packagist](https://packagist.org/packages/juanparati/mobile-numbers)[ RSS](/packages/juanparati-mobile-numbers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (15)Used By (0)

[![Test](https://github.com/juanparati/mobilenumbers/actions/workflows/test.yml/badge.svg)](https://github.com/juanparati/mobilenumbers/actions/workflows/test.yml/badge.svg)

MobileNumbers
=============

[](#mobilenumbers)

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

[](#what-is-it)

A library that validate and parse mobile phone numbers.

Right now only phone numbers from the following countries are validated:

CountryCodeGermanyDEDenmarkDKSpainESFinlandFIFranceFRItalyITNorwayNOPolandPLSwedenSESouth AfricaZAFeel free to fork this project and add new countries.

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

[](#installation)

```
composer require juanparati/mobile-numbers

```

How it works
------------

[](#how-it-works)

Validate a phone number:

```
Validator::country('ES')->isValid('651365485');
```

It is possible to validate phone numbers that contains the international country code:

```
Validator::country('DK')->isValid('+4560514180');
Validator::country('SE')->isValid('0046767164315');
```

The library provides helper that convert different phone number formats to E.164:

```
$validator = Validator::country('PL');
$raw_number = '(669) 823-955';

$e164_number = $validator->helper->convertToE164($raw_number);   // Convert number to "669823955"
echo ($validator->isValid($e164_number) ? 'Valid!' : 'Not Valid!');

$validator = Validator::country('SE');
$raw_number = '(+46) 7 37322 0-66';

$e164_number = $validator->helper->convertToE164($raw_number);   // Convert number to "+46737322066"
echo ($validator->isValid($e164_number) ? 'Valid!' : 'Not Valid!');
```

It is also possible to add a valid country code to number without country code:

```
Validator::country('SE')->addCountryCode('0737321066');    // +46737321066
Validator::country('DK')->addCountryCode('60515290');      // +4560515290

Validator::country('DK')->addCountryCode('+4560515290');   // +4560515290  (Country code is not added again)
Validator::country('DK')->addCountryCode('004560515290');  // 004560515290 (Country code is not added again)
```

or stripe the country code

```
Validator::country('SE')->stripCountryCode('0046737321066');   // 0737321066
Validator::country('FI')->stripCountryCode('00358411234567');  // 0411234567
Validator::country('ES')->stripCountryCode('+34670862595');    // 670862595
```

Other methods:

```
Validator::country('ES')->helper->hasCountryCode('0030670862595'); // True
Validator::country('ES')->hasValidCountryCode('0030670862595');  // False
```

Definitions list
----------------

[](#definitions-list)

Using the helper method "getAllDefinitions" it will obtain the information about the all the codes used in all the definitions:

```
$definitions = Helper::getAllDefinitions();
```

The definitions include country prefix code, country code and country flag information.

Identify phone numbers
----------------------

[](#identify-phone-numbers)

Using the helper method "identifyNumber" is possible the identify the country which belongs the phone number. The phone number should contains the international prefix.

Example:

```
Helper::identifyNumber('+4560514180');  // Returns DK
```

Add your country definition
---------------------------

[](#add-your-country-definition)

1. Fork this project
2. Add a new definition into ./src/Definitions
3. Add a new unit test into ./tests/Definitions

Backers and contributors
------------------------

[](#backers-and-contributors)

- [Matchbanker.fi](https://matchbanker.fi) (Backer)

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance87

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~234 days

Recently: every ~158 days

Total

14

Last Release

63d ago

Major Versions

0.9.4 → 1.0.02020-03-19

1.5.0 → 2.0.02026-03-17

PHP version history (3 changes)0.9PHP &gt;=7.0

1.0.0PHP &gt;=7.1

2.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/4caf72b4d969cfb8cdfbdc1d594c85b51c9316caf76b80aa0f9de7e3736cf59f?d=identicon)[juanparati](/maintainers/juanparati)

---

Top Contributors

[![juanparati](https://avatars.githubusercontent.com/u/835173?v=4)](https://github.com/juanparati "juanparati (24 commits)")[![JuanLeadSupply](https://avatars.githubusercontent.com/u/26138256?v=4)](https://github.com/JuanLeadSupply "JuanLeadSupply (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/juanparati-mobile-numbers/health.svg)

```
[![Health](https://phpackages.com/badges/juanparati-mobile-numbers/health.svg)](https://phpackages.com/packages/juanparati-mobile-numbers)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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