PHPackages                             tapfury/laravel-phone - 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. tapfury/laravel-phone

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

tapfury/laravel-phone
=====================

Adds a phone validator to Laravel and Lumen based on Google's libphonenumber API.

3.0.1(8y ago)03.2k↓100%MITPHP

Since Feb 28Pushed 8y ago3 watchersCompare

[ Source](https://github.com/Tapfury/Laravel-Phone)[ Packagist](https://packagist.org/packages/tapfury/laravel-phone)[ RSS](/packages/tapfury-laravel-phone/feed)WikiDiscussions master Synced 1mo ago

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

Laravel Phone
=============

[](#laravel-phone)

[![Build Status](https://camo.githubusercontent.com/9c3117b45603b9c68d946a13330b4369e269622b1e6301025db81d8bcee2937c/68747470733a2f2f7472617669732d63692e6f72672f50726f706167616e69737461732f4c61726176656c2d50686f6e652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Propaganistas/Laravel-Phone)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/06e6586299b1ca02c263ed05a7603345346ae532c95bfcfbcf45288a7fd8565d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f50726f706167616e69737461732f4c61726176656c2d50686f6e652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Propaganistas/Laravel-Phone/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/f352cfbf558db1b3472e8542296fe5c2354eef55e61f48fa726db0459a93b8d0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f50726f706167616e69737461732f4c61726176656c2d50686f6e652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Propaganistas/Laravel-Phone/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/a73ec84b84d099e5b509aab233cce2d47540177130cc769bc7beafe6e7f9129c/68747470733a2f2f706f7365722e707567782e6f72672f70726f706167616e69737461732f6c61726176656c2d70686f6e652f762f737461626c65)](https://packagist.org/packages/propaganistas/laravel-phone)[![Total Downloads](https://camo.githubusercontent.com/a65787eac67db4e59f6ef52659fcec9baf90d64eb35211cdef6a3b65e0187765/68747470733a2f2f706f7365722e707567782e6f72672f70726f706167616e69737461732f6c61726176656c2d70686f6e652f646f776e6c6f616473)](https://packagist.org/packages/propaganistas/laravel-phone)[![License](https://camo.githubusercontent.com/3a1ad253834ad7438ce19d880bcb9326f0c7505538df867afb2945abbf384a89/68747470733a2f2f706f7365722e707567782e6f72672f70726f706167616e69737461732f6c61726176656c2d70686f6e652f6c6963656e7365)](https://packagist.org/packages/propaganistas/laravel-phone)

Adds a phone validator &amp; formatter to Laravel 4 &amp; 5 and Lumen based on the [PHP port](https://github.com/giggsey/libphonenumber-for-php) of [Google's libphonenumber API](https://github.com/googlei18n/libphonenumber) by [giggsey](https://github.com/giggsey).

### Installation

[](#installation)

Run the following command to install the latest version of the package

```
composer require propaganistas/laravel-phone
```

**Laravel**

In your app config, add the Service Provider to the `$providers` array *(only for Laravel 5.4 or below)*:

```
'providers' => [
   ...
   Propaganistas\LaravelPhone\LaravelPhoneServiceProvider::class,
],
```

In your languages directory, add for each language an extra language line for the validator:

```
"phone" => "The :attribute field contains an invalid number.",
```

**Lumen**

In `bootstrap/app.php`, register the Service Provider

```
$app->register(Propaganistas\LaravelPhone\LaravelPhoneServiceProvider::class);
```

### Validator

[](#validator)

To validate a field using the phone validator, use the `phone` keyword in your validation rules array. The phone validator is able to operate in **three** ways.

- You either specify [*ISO 3166-1 alpha-2 compliant*](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) country codes yourself as parameters for the validator, e.g.:

    ```
    'phonefield'  => 'phone:US,BE',
    ```

    The validator will check if the number is valid in at least one of provided countries, so feel free to add as many country codes as you like.
- You don't specify any parameters but you plug in a dedicated country input field (keyed by *ISO 3166-1 compliant* country codes) to allow end users to supply a country on their own. The easiest method by far is to install the [Laravel-Intl](https://github.com/Propaganistas/Laravel-Intl) package. Make sure the country field is named similar as the phone field but with *\_country* appended for automatic discovery, or provide your custom country field name as a parameter to the validator:

    ```
    'phonefield'            => 'phone',
    'phonefield_country'    => 'required_with:phonefield',
    ```

    ```
    'phonefield'            => 'phone:custom_country_field',
    'custom_country_field'  => 'required_with:phonefield',
    ```

    If using [Laravel-Intl](https://github.com/Propaganistas/Laravel-Intl), you could then use the following snippet to populate a country selection list. It will automatically present translated country names according to your application locale:

    ```
    Country::all()
    ```
- You instruct the validator to detect which country the number belongs to using the `AUTO` keyword (and optionally any fallback countries):

    ```
    'phonefield'  => 'phone:AUTO,US',
    ```

    The validator will try to extract the country from the number itself and then check if the number is valid for that country. If the country could not be guessed it will be validated using the fallback countries if provided. Note that country guessing will only work when phone numbers are entered in *international format* (prefixed with a `+` sign, e.g. +32 ....). Leading double zeros will **NOT** be parsed correctly as this isn't an established consistency.

To specify constraints on the number type, just append the allowed types to the end of the parameters, e.g.:

```
'phonefield'  => 'phone:US,BE,mobile',
```

The most common types are `mobile` and `fixed_line`, but feel free to use any of the types defined [here](https://github.com/giggsey/libphonenumber-for-php/blob/master/src/PhoneNumberType.php).

You can also enable more lenient validation (for example, fixed lines without area codes) by using the `LENIENT` parameter. This feature inherently doesn't play well with country autodetection and number type validation, so use such combo at own risk.

```
'phonefield'  => 'phone:LENIENT,US',
```

### Formatter

[](#formatter)

Format a phone number using the `phone()` helper function. `$country_code` is the country the phone number belongs to.

```
phone($phone_number, $country_code = null, $format = PhoneNumberFormat::INTERNATIONAL)
```

Always try to provide a `$country_code` in order for the phone number to be recognized correctly. If no `$country_code` was given, the current application locale will be used as a sensible default. The `$format` parameter defines the output format and is optional. The format defaults to international format but can be any constant of `libphonenumber\PhoneNumberFormat`.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 90.8% 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 ~41 days

Recently: every ~54 days

Total

31

Last Release

3219d ago

Major Versions

1.2.0 → 2.02015-02-27

1.3.0 → 2.1.12015-04-29

1.3.2 → 2.1.22015-05-04

2.8.5 → 3.0.12017-07-19

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

1.1.1PHP &gt;=5.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1173636?v=4)[William](/maintainers/gcphost)[@gcphost](https://github.com/gcphost)

---

Top Contributors

[![Propaganistas](https://avatars.githubusercontent.com/u/6680176?v=4)](https://github.com/Propaganistas "Propaganistas (128 commits)")[![jgrossi](https://avatars.githubusercontent.com/u/1175275?v=4)](https://github.com/jgrossi "jgrossi (3 commits)")[![xfxf](https://avatars.githubusercontent.com/u/138684?v=4)](https://github.com/xfxf "xfxf (2 commits)")[![gcphost](https://avatars.githubusercontent.com/u/1173636?v=4)](https://github.com/gcphost "gcphost (2 commits)")[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (2 commits)")[![mikemand](https://avatars.githubusercontent.com/u/745184?v=4)](https://github.com/mikemand "mikemand (1 commits)")[![giggsey](https://avatars.githubusercontent.com/u/305730?v=4)](https://github.com/giggsey "giggsey (1 commits)")[![ashnewmanjones](https://avatars.githubusercontent.com/u/29983014?v=4)](https://github.com/ashnewmanjones "ashnewmanjones (1 commits)")[![Gounlaf](https://avatars.githubusercontent.com/u/236413?v=4)](https://github.com/Gounlaf "Gounlaf (1 commits)")

---

Tags

laravelvalidationlumenphonelibphonenumber

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tapfury-laravel-phone/health.svg)

```
[![Health](https://phpackages.com/badges/tapfury-laravel-phone/health.svg)](https://phpackages.com/packages/tapfury-laravel-phone)
```

###  Alternatives

[propaganistas/laravel-phone

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

3.0k35.7M107](/packages/propaganistas-laravel-phone)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

759569.4k13](/packages/wendelladriel-laravel-validated-dto)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)[galahad/laravel-addressing

Laravel package providing addressing functionality

70316.6k](/packages/galahad-laravel-addressing)

PHPackages © 2026

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