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

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

atsight/laravel-phone
=====================

A phone validator for Laravel using the free Twilio phone lookup service. This fork supports Laravel 8.8

01PHP

Since Aug 25Pushed 3y agoCompare

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

READMEChangelogDependenciesVersions (2)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

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 Bus Factor1

Top contributor holds 93.9% 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/8d226c372171d8cee042d8476a1a5a5ed546b3b11f9f175ca5b53848086ce66a?d=identicon)[atsight](/maintainers/atsight)

---

Top Contributors

[![ellisio](https://avatars.githubusercontent.com/u/127468?v=4)](https://github.com/ellisio "ellisio (46 commits)")[![atraikov](https://avatars.githubusercontent.com/u/1878446?v=4)](https://github.com/atraikov "atraikov (1 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)")

### Embed Badge

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

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