PHPackages                             blobfolio/blob-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. blobfolio/blob-phone

AbandonedArchivedLibrary

blobfolio/blob-phone
====================

A light(er)weight implementation of Google's amazing libphonenumber for PHP.

8.0.0(7y ago)51.8kWTFPLPHPPHP &gt;= 7.0

Since Jan 27Pushed 6y ago3 watchersCompare

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

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

blob-phone
==========

[](#blob-phone)

blob-phone is a light(er)-weight implementation of Google's amazing [libphonenumber](https://github.com/googlei18n/libphonenumber) for PHP.

[![Build Status](https://camo.githubusercontent.com/aae837b30d37af26d9c9bd38ec2d2d1f236dc5285516c3b63d63b86cf26ddead/68747470733a2f2f7472617669732d63692e6f72672f426c6f62666f6c696f2f626c6f622d70686f6e652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Blobfolio/blob-phone)

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

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Use](#use)
- [Javascript](#javascript)
- [License](#license)

Features
--------

[](#features)

blob-phone is primarily concerned with validating and formatting arbitrary telephone numbers in international format (e.g. `+1 201-555-0123`). Along the way it also manages to gather information about a number's:

- Country
- Continent
- Type (e.g. `mobile`, `voip`, etc.)

Other data and formatting features from `libphonenumber` have been stripped out to reduce the library's size. For a more comprehensive implementation of `libphonenumber` written for PHP, take a look at [libphonenumber-for-php](https://github.com/giggsey/libphonenumber-for-php).

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

[](#installation)

The PHP library for blob-phone requires:

- PHP 7.0+
- [blobfolio/blob-common](https://github.com/Blobfolio/blob-common)

Install with Composer:

```
composer require "blobfolio/blob-phone:dev-master"
```

Use
---

[](#use)

#### Get started

[](#get-started)

```
$phone = new blobfolio\phone\phone($phone_number, $country_code='US');
```

The constructor accepts two arguments:

- (*string*) Phone number (pre-formatted or not);
- (*string*) (*optional*) ISO country code (suspected); Default: `"US"`

Providing a probable country of origin will help with identification, so is recommended. Otherwise your number may end up on the wrong side of the planet.

blob-phone uses a brute-force technique to identify and format a phone number, prioritizing tests as follows:

- The country provided;
- Other countries with the same prefix;
- Other countries on the same continent;
- Everywhere else, alphabetically;

#### Check it

[](#check-it)

```
if ($phone->is_phone($types=array())) {
    ...
}
```

This method accepts an optional array of types of phone numbers in case you are looking for something specific. Type detection is hit or miss, so if you require high accuracy, you should verify this some other way.

The possible types are:

- `"fixed"`, i.e. landline
- `"mobile"`
- `"pager"`
- `"personal_number"`
- `"premium_rate"`, e.g. your favorite party line
- `"shared_cost"`
- `"toll_free"`
- `"voicemail"`
- `"voip"`, e.g. Google Voice

This method returns `TRUE` or `FALSE`.

#### Pull It

[](#pull-it)

```
// If you only want the number, you can typecast it:
$formatted = (string) $phone; //+598 9423 1234

// If you want more details:
print_r($phone->get_data());
/*
Array(
    [country] => CA
    [prefix] => 1
    [region] => North America
    [types] => Array(
        [0] => fixed
        [1] => mobile
    )
    [number] => +1 204-234-5678
)
*/
```

#### All Together Now...

[](#all-together-now)

```
$phone = '1012345678';
$country = 'CN';

$phone = (string) blobfolio\phone\phone($phone, $country);
if (strlen($phone)) {
    echo "Your pretty phone number is: $phone";
}
else {
    echo "I don't think that was right...";
}
```

Javascript
----------

[](#javascript)

blob-phone is also available as a dependency-free Javascript library. To use it, simply include `lib/js/blob-phone.min.js` in your project.

This library has a single method: `blobPhone.parse()`, which takes two arguments:

- (*string*) Phone number (pre-formatted or not);
- (*string*) (*optional*) ISO country code (suspected); Default: `"US"`

Providing a probable country of origin will help with identification, so is recommended. Otherwise your number may end up on the wrong side of the planet.

This will return `FALSE` if the number could not be parsed, or an object containing the number details, like:

```
var parsed = blobPhone.parse(2015550123);
/*
{
    country: "US",
    number: "+1 201-555-0123",
    prefix: 1,
    region: "North America",
    types: [
        "fixed",
        "mobile"
    ]
}
*/
```

License
-------

[](#license)

Copyright © 2018 [Blobfolio, LLC](https://blobfolio.com) &lt;&gt;

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2.

```
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.

```

### Donations

[](#donations)

   [![Bitcoin QR](https://camo.githubusercontent.com/02c1aab6dc8b7908cb540a77b3df80ff1781b137aa6e4de8e795aac613ffe124/68747470733a2f2f626c6f62666f6c696f2e636f6d2f77702d636f6e74656e742f7468656d65732f62332f7376672f6274632d6769746875622e737667)](https://camo.githubusercontent.com/02c1aab6dc8b7908cb540a77b3df80ff1781b137aa6e4de8e795aac613ffe124/68747470733a2f2f626c6f62666f6c696f2e636f6d2f77702d636f6e74656e742f7468656d65732f62332f7376672f6274632d6769746875622e737667) If you have found this work useful and would like to contribute financially, Bitcoin tips are always welcome!

**1Af56Nxauv8M1ChyQxtBe1yvdp2jtaB1GF**

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~101 days

Recently: every ~118 days

Total

6

Last Release

2888d ago

Major Versions

0.8 → 1.0.02017-07-03

1.0.0 → 8.0.02018-06-17

PHP version history (2 changes)0.6PHP &gt;= 7.0

0.8PHP &gt;= 5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/74cb6ecb5887fa7b80c3aa263b6016e403989d28e93a35420536740599d6d909?d=identicon)[joshstoik1](/maintainers/joshstoik1)

---

Top Contributors

[![joshstoik1](https://avatars.githubusercontent.com/u/403248?v=4)](https://github.com/joshstoik1 "joshstoik1 (95 commits)")

---

Tags

international-telephonejavascriptlibphonenumberphone-formattingphone-numberphpphpphonelibphonenumberformatting

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/blobfolio-blob-phone/health.svg)

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

###  Alternatives

[propaganistas/laravel-phone

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

3.0k35.7M107](/packages/propaganistas-laravel-phone)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

120220.7k1](/packages/ellaisys-aws-cognito)[rynpsc/craft-phone-number

International phone number field.

2265.9k](/packages/rynpsc-craft-phone-number)

PHPackages © 2026

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