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

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

ellisio/laravel-phone
=====================

A phone validator for Laravel using the free Twilio phone lookup service.

v8.0.0(6y ago)1130.0k9[1 issues](https://github.com/ellisio/laravel-phone/issues)[2 PRs](https://github.com/ellisio/laravel-phone/pulls)MITPHPPHP &gt;=7.2.5

Since Jan 11Pushed 4y agoCompare

[ Source](https://github.com/ellisio/laravel-phone)[ Packagist](https://packagist.org/packages/ellisio/laravel-phone)[ Docs](https://github.com/ellisio/laravel-phone)[ RSS](/packages/ellisio-laravel-phone/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (7)Versions (20)Used By (0)

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

[](#laravel-phone)

 [![Latest Stable Version](https://camo.githubusercontent.com/018c54808833bc31bf66178b53e44fd66f9a1dbb3524928e04a7cb89b32d74f9/68747470733a2f2f706f7365722e707567782e6f72672f656c6c6973696f2f6c61726176656c2d70686f6e652f762f737461626c652e737667)](https://packagist.org/packages/ellisio/laravel-phone) [![License](https://camo.githubusercontent.com/7b90201faeac90f756ac4f4bdfe703f1cac65c8d3e25e77ac8e8001cad8c37fe/68747470733a2f2f706f7365722e707567782e6f72672f656c6c6973696f2f6c61726176656c2d70686f6e652f6c6963656e73652e737667)](https://packagist.org/packages/ellisio/laravel-phone) [![Total Downloads](https://camo.githubusercontent.com/1507751f80a30d352e305a2befbbefed4f332eea6b35072cbe4bb774b60a304b/68747470733a2f2f706f7365722e707567782e6f72672f656c6c6973696f2f6c61726176656c2d70686f6e652f642f746f74616c2e737667)](https://packagist.org/packages/ellisio/laravel-phone) [![Build Status](https://camo.githubusercontent.com/52025b36dbb5de972432d03399735326a429abca47bb869fb7b62ebdff86a924/68747470733a2f2f636972636c6563692e636f6d2f67682f656c6c6973696f2f6c61726176656c2d70686f6e652e7376673f7374796c653d736869656c64)](https://circleci.com/gh/ellisio/laravel-phone) [![](https://camo.githubusercontent.com/fcbc78d55999911d67589ad633bc67c67b58eb25e048eb51a5c4c67587b81799/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f656c6c6973696f2f6c61726176656c2d70686f6e652f6261646765732f6770612e737667)](https://codeclimate.com/github/ellisio/laravel-phone) [![](https://camo.githubusercontent.com/20da9193a95619f565baaddcbbf4a10997df1601c8948b731108a2815fee629b/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f656c6c6973696f2f6c61726176656c2d70686f6e652f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/ellisio/laravel-phone/coverage)

- [Introduction](#introduction)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Phone validation](#phone-validation)
    - [Country validation](#country-validation)
    - [Formatting phone numbers](#formatting-phone-numbers)
    - [Creating phone number objects](#creating-phone-number-objects)
    - [Handling invalid numbers](#handling-invalid-numbers)
- [Support](#support)

Introduction
------------

[](#introduction)

A phone validator for Laravel 6+ using the free [Twilio Lookup API](https://www.twilio.com/lookup).

This package gives developers the ability to validate phone numbers and format phone numbers. All data will be pulled from the Twilio Lookup API.

Validation can be configured to check if the number is valid, or if it is valid within a given list of [ISO-3166-1 Alpha 2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country codes.

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

[](#installation)

Install via composer:

```
composer require ellisio/laravel-phone

```

Add your Twilio credentials to your `.env` file. *If you don't have a Twilio account you can register one [here](https://www.twilio.com/) for free.*

```
TWILIO_ACCOUNT_SID=xxxxxxxx
TWILIO_AUTH_TOKEN=xxxxxxxx

```

Configuration
-------------

[](#configuration)

If you want to customize the configuration for this package, you can publish the config file to `/config/phone.php` by running the following command:

```
php artisan vendor:publish --provider=EllisIO/Phone/PhoneServiceProvider --tag=laravel-phone-config
```

If you want to customize the output of the validation messages, you can publish the translations file to `/lang/vendor/laravel-phone` by running the following command:

```
php artisan vendor:publish --provider=EllisIO/Phone/PhoneServiceProvider --tag=laravel-phone-translations
```

Usage
-----

[](#usage)

### Phone validation

[](#phone-validation)

If you need to verify that the given number is valid and that is all, use the `phone` rule.

```
return [
    'phone' => 'required|phone',
];
```

### Country validation

[](#country-validation)

If you need to validate that the given number is valid in a list of countries, use the `phone_country:US,CA` rule. You can list as many [ISO-3166-1 Alpha 2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) as you wish delimited by a comma.

```
return [
    'phone' => 'required|phone_country:US,CA',
];
```

### Formatting phone numbers

[](#formatting-phone-numbers)

If you want to format the phone number using `INTERNATIONAL_FORMAT` use the following code:

```
Phone::formatNumber('5551234567');
```

### Creating phone number objects

[](#creating-phone-number-objects)

This library includes the ability to generate a `Phone` object. This object contains the following details about a number:

- `countryCode`: ISO-3166 alpha 2 country code.
- `number`: E.164 number.
- `formattedNumber`: National formatted number.

```
$phone = Phone::getPhone('5551234567');
$phone->getNumber(); // Returns "+15551234567"
$phone->getNationalNumber(); // Returns "5551234567"
$phone->getFormattedNumber(); // Returns "(555) 123-4567"
$phone->getCountry(); // Returns "US"
$phone->getCountryCallingCode(); // Returns "1"
```

### Handling invalid numbers

[](#handling-invalid-numbers)

Sometimes you may have bad data, it happens. To handle this, simply check to see if `null` was returned.

```
if (! $phone = Phone::getPhone('123')) {
    echo "Invalid number provided.";
}
```

Support
-------

[](#support)

Need help? Create an [issue](https://github.com/ellisio/laravel-phone/issues).

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 95.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 ~64 days

Recently: every ~52 days

Total

19

Last Release

2254d ago

Major Versions

v3.0.5 → v4.0.02018-05-21

v4.0.1 → v5.0.02018-09-18

v5.1.0 → v6.0.02019-08-14

v6.1.0 → v7.0.02019-10-09

v7.0.1 → v8.0.02020-03-10

PHP version history (4 changes)v0.1.0-alphaPHP &gt;=7.0

v4.0.0PHP ^7.1.3

v7.0.0PHP ^7.2

v8.0.0PHP &gt;=7.2.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/549e10fc229537a83d99e013a9c8bdb29e405e3465bb0dafa1c819526da2f18b?d=identicon)[ellisio](/maintainers/ellisio)

---

Top Contributors

[![ellisio](https://avatars.githubusercontent.com/u/127468?v=4)](https://github.com/ellisio "ellisio (46 commits)")[![bellalMohamed](https://avatars.githubusercontent.com/u/18222754?v=4)](https://github.com/bellalMohamed "bellalMohamed (1 commits)")[![CasperLaiTW](https://avatars.githubusercontent.com/u/5094008?v=4)](https://github.com/CasperLaiTW "CasperLaiTW (1 commits)")

---

Tags

formatterlaravelvalidatorvalidationphonetwilioformat

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/ellisio-laravel-phone/health.svg)](https://phpackages.com/packages/ellisio-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)[proengsoft/laravel-jsvalidation

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

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

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

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)[sunspikes/clamav-validator

Custom Laravel 5 anti-virus validator for file uploads.

3651.8M3](/packages/sunspikes-clamav-validator)

PHPackages © 2026

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