PHPackages                             genderapi/phone-validator - 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. genderapi/phone-validator

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

genderapi/phone-validator
=========================

PHP SDK for validating and formatting phone numbers using the GenderAPI Phone Number Validation &amp; Formatter API (https://genderapi.io)

v1.0.5(9mo ago)10MITPHPPHP &gt;=7.4

Since Aug 3Pushed 9mo agoCompare

[ Source](https://github.com/GenderAPI/phone-validator-php)[ Packagist](https://packagist.org/packages/genderapi/phone-validator)[ RSS](/packages/genderapi-phone-validator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

📞 Phone Number Validation &amp; Formatter API (PHP SDK)
=======================================================

[](#-phone-number-validation--formatter-api-php-sdk)

The `phone-validator-php` library uses the official [GenderAPI Phone Number Validation &amp; Formatter API](https://www.genderapi.io/docs-phone-validation-formatter-api) to validate and format phone numbers from over 240 countries.

Whether your users enter phone numbers in various formats (e.g., `12128675309`, `+1 212 867 5309`, `001-212-867-5309`), this library will intelligently detect, validate, and convert the input into a standardized E.164 format (e.g., `+12128675309`).

---

✅ Features
----------

[](#-features)

- Converts phone numbers to **E.164** format
- Validates if number is real and structurally possible
- Detects number type: mobile, landline, VoIP, etc.
- Identifies region/city based on area code
- Includes country-level metadata (e.g. ISO code)
- Built with PHP, works with Composer autoloading

---

📦 Installation
--------------

[](#-installation)

```
composer require genderapi/phone-validator
```

Or manually:

```
git clone https://github.com/GenderAPI/phone-validator-php.git
cd phone-validator-php
composer install
```

---

🚀 Usage
-------

[](#-usage)

```
require_once __DIR__ . '/vendor/autoload.php';

use GenderApi\PhoneValidator;

$validator = new PhoneValidator('YOUR_API_KEY');

$response = $validator->validate('+1 212 867 5309', 'US');

print_r($response);
```

---

📝 Input Parameters
------------------

[](#-input-parameters)

```
validate(string $number, string|null $address = null): array
```

ParameterTypeRequiredDescription`number`string✅ YesPhone number in any format`address`stringOptionalISO country code (`US`), full country name (`Turkey`), or city name (`Berlin`) – helps resolve local numbers**Example:**

```
$validator->validate('2128675309', 'US');
```

---

📤 API Response
--------------

[](#-api-response)

```
{
  "status": true,
  "remaining_credits": 15709,
  "expires": 0,
  "duration": "18ms",
  "regionCode": "US",
  "countryCode": 1,
  "country": "United States",
  "national": "(212) 867-5309",
  "international": "+1 212-867-5309",
  "e164": "+12128675309",
  "isValid": true,
  "isPossible": true,
  "numberType": "FIXED_LINE_OR_MOBILE",
  "nationalSignificantNumber": "2128675309",
  "rawInput": "+1 212 867 5309",
  "isGeographical": true,
  "areaCode": "212",
  "location": "New York City (Manhattan)"
}
```

---

📘 Response Field Reference
--------------------------

[](#-response-field-reference)

FieldTypeDescription`status`BooleanWas the request successful`remaining_credits`IntegerRemaining API credits`regionCode`StringISO 3166-1 alpha-2 code (e.g. `US`)`country`StringCountry name`e164`StringNumber formatted to E.164`isValid`BooleanIs number valid according to numbering rules`isPossible`BooleanIs number structurally possible`numberType`StringNumber type (`MOBILE`, `FIXED_LINE`, etc.)`areaCode`StringArea code from input`location`StringCity/region matched from area code---

🔢 Number Type Values
--------------------

[](#-number-type-values)

ValueDescription`FIXED_LINE`Landline`MOBILE`Mobile phone`FIXED_LINE_OR_MOBILE`Ambiguous, could be both`TOLL_FREE`e.g. 800 numbers`PREMIUM_RATE`Expensive premium numbers`SHARED_COST`Cost shared between parties`VOIP`Internet-based phone`PERSONAL_NUMBER`Forwarding number`PAGER`Obsolete pager number`VOICEMAIL`Voicemail access`UNKNOWN`Cannot be determined---

ℹ️ More Information
-------------------

[](#ℹ️-more-information)

- Supports 240+ countries and territories
- Detects mobile vs. landline automatically
- Great for sign-up forms, CRMs, messaging tools, and more
- More details: [GenderAPI Docs](https://www.genderapi.io/docs-phone-validation-formatter-api)

---

📄 License
---------

[](#-license)

MIT License © [GenderAPI](https://www.genderapi.io)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance56

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75% 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 ~0 days

Total

4

Last Release

288d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/32ce0050c4aaed2ca6b1b4d29c80f84b77ba62bc1b3529c72f8911e68e1b3e0b?d=identicon)[GenderAPI](/maintainers/GenderAPI)

---

Top Contributors

[![omurtlak](https://avatars.githubusercontent.com/u/8090041?v=4)](https://github.com/omurtlak "omurtlak (3 commits)")[![GenderAPI](https://avatars.githubusercontent.com/u/38208531?v=4)](https://github.com/GenderAPI "GenderAPI (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/genderapi-phone-validator/health.svg)

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

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