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

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

christianjombo/laravel-phone
============================

This package adds phone number validation functionality to Laravel and Lumen based on Google's libphonenumber API.

211PHP

Since Nov 3Pushed 6y ago1 watchersCompare

[ Source](https://github.com/christianjombo/Laravel-Phone)[ Packagist](https://packagist.org/packages/christianjombo/laravel-phone)[ RSS](/packages/christianjombo-laravel-phone/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#laravel-phone)

This package adds phone number functionality to Laravel 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).

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
    - [Laravel](#laravel)
    - [Lumen](#lumen)
- [Validation](#validation)
- [Utility class](#utility-phonenumber-class)
    - [Formatting](#formatting)
    - [Number information](#number-information)
    - [Helper function](#helper-function)

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

[](#installation)

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

```
composer require christianjombo/laravel-phone
```

### Laravel

[](#laravel)

If you don't use auto-discovery, open up your app config and add the Service Provider to the `$providers` array:

```
'providers' => [
   ...
   ChristianJombo\LaravelPhone\PhoneServiceProvider::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

[](#lumen)

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

```
$app->register(ChristianJombo\LaravelPhone\PhoneServiceProvider::class);
```

Validation
----------

[](#validation)

To validate a phone number, use the `phone` keyword in your validation rules array or use the `Phone` rule class to define the rule in an expressive way. 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',
    // 'phonefield'    => Rule::phone()->country(['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 provide a dedicated country input field (keyed by *ISO 3166-1 compliant* country codes) to allow end users to supply a country on their own. 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'         => Rule::phone()
    'phonefield_country'    => 'required_with:phonefield',
    ```

    ```
    'phonefield'            => 'phone:custom_country_field',
    // 'phonefield'         => Rule::phone()->countryField('custom_country_field')
    'custom_country_field'  => 'required_with:phonefield',
    ```
- 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',
    // 'phonefield'    => Rule::phone()->detect()->country('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',
// 'phonefield'    => Rule::phone()->country(['US', 'BE'])->type('mobile')
// 'phonefield'    => Rule::phone()->country('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',
// 'phonefield'    => Rule::phone()->lenient()->country('US')
```

Utility PhoneNumber class
-------------------------

[](#utility-phonenumber-class)

A phone number can be wrapped in the `ChristianJombo\LaravelPhone\PhoneNumber` class to enhance it with useful utility methods. It's safe to directly reference these objects in views or when saving to the database as they will degrade gracefully to the E164 format.

```
use ChristianJombo\LaravelPhone\PhoneNumber;

(string) PhoneNumber::make('+3212/34.56.78');              // +3212345678
(string) PhoneNumber::make('012 34 56 78', 'BE');          // +3212345678
(string) PhoneNumber::make('012345678')->ofCountry('BE');  // +3212345678
```

### Formatting

[](#formatting)

A PhoneNumber can be formatted in various ways:

```
PhoneNumber::make('012 34 56 78', 'BE')->format($format);       // See libphonenumber\PhoneNumberFormat
PhoneNumber::make('012 34 56 78', 'BE')->formatE164();          // +3212345678
PhoneNumber::make('012 34 56 78', 'BE')->formatInternational(); // +32 12 34 56 78
PhoneNumber::make('012 34 56 78', 'BE')->formatRFC3966();       // +32-12-34-56-78
PhoneNumber::make('012/34.56.78', 'BE')->formatNational();      // 012 34 56 78

// Formats so the number can be called straight from the provided country.
PhoneNumber::make('012 34 56 78', 'BE')->formatForCountry('BE'); // 012 34 56 78
PhoneNumber::make('012 34 56 78', 'BE')->formatForCountry('NL'); // 00 32 12 34 56 78
PhoneNumber::make('012 34 56 78', 'BE')->formatForCountry('US'); // 011 32 12 34 56 78

// Formats so the number can be clicked on and called straight from the provided country using a cellphone.
PhoneNumber::make('012 34 56 78', 'BE')->formatForMobileDialingInCountry('BE'); // 012345678
PhoneNumber::make('012 34 56 78', 'BE')->formatForMobileDialingInCountry('NL'); // +3212345678
PhoneNumber::make('012 34 56 78', 'BE')->formatForMobileDialingInCountry('US'); // +3212345678
```

### Number information

[](#number-information)

Get some information about the phone number:

```
PhoneNumber::make('012 34 56 78', 'BE')->getType();              // 'fixed_line'
PhoneNumber::make('012 34 56 78', 'BE')->isOfType('fixed_line'); // true
PhoneNumber::make('012 34 56 78', 'BE')->getCountry();           // 'BE'
PhoneNumber::make('012 34 56 78', 'BE')->isOfCountry('BE');      // true
PhoneNumber::make('+32 12 34 56 78')->isOfCountry('BE');         // true
```

### Helper function

[](#helper-function)

The package exposes the `phone()` helper function that returns a `ChristianJombo\LaravelPhone\PhoneNumber` instance or the formatted string if `$format` was provided:

```
phone($number, $country = [], $format = null)
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/62b7de1b582c174fe79c5c24ae35346b1620231bfffbd0a5647b59d605866297?d=identicon)[christianjombo](/maintainers/christianjombo)

---

Top Contributors

[![christianjombo](https://avatars.githubusercontent.com/u/30735214?v=4)](https://github.com/christianjombo "christianjombo (19 commits)")

---

Tags

laravellibphonenumberlumenphonevalidation

### Embed Badge

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

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

###  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)
