PHP version of Google's phone number handling library

Overview

libphonenumber for PHP Build Status Coverage Status

Total Downloads Downloads per month Latest Stable Version License

What is it?

A PHP library for parsing, formatting, storing and validating international phone numbers. This library is based on Google's libphonenumber.

Installation

PHP versions 5.3 up to PHP 8.0 are currently supported.

The PECL mbstring extension is required.

It is recommended to use composer to install the library.

$ composer require giggsey/libphonenumber-for-php

You can also use any other PSR-4 compliant autoloader.

If you do not use composer, ensure that you also load any dependencies that this project has, such as giggsey/locale.

Documentation

Online Demo

An online demo is available, and the source can be found at giggsey/libphonenumber-example.

Highlights of functionality

  • Parsing/formatting/validating phone numbers for all countries/regions of the world.
  • getNumberType - gets the type of the number based on the number itself; able to distinguish Fixed-line, Mobile, Toll-free, Premium Rate, Shared Cost, VoIP and Personal Numbers (whenever feasible).
  • isNumberMatch - gets a confidence level on whether two numbers could be the same.
  • getExampleNumber/getExampleNumberByType - provides valid example numbers for all countries/regions, with the option of specifying which type of example phone number is needed.
  • isValidNumber - full validation of a phone number for a region using length and prefix information.
  • PhoneNumberOfflineGeocoder - provides geographical information related to a phone number.
  • PhoneNumberToTimeZonesMapper - provides timezone information related to a phone number.
  • PhoneNumberToCarrierMapper - provides carrier information related to a phone number.

Versioning

This library will try to follow the same version numbers as Google. There could be additional releases where needed to fix critical issues that can not wait until the next release from Google.

This does mean that this project may not follow Semantic Versioning, but instead Google's version policy. As a result, jumps in major versions may not actually contain any backwards incompatible changes. Please read the release notes for such releases.

Google try to release their versions according to Semantic Versioning, as laid out of in their Versioning Guide.

Quick Examples

Let's say you have a string representing a phone number from Switzerland. This is how you parse/normalize it into a PhoneNumber object:

$swissNumberStr = "044 668 18 00";
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
try {
    $swissNumberProto = $phoneUtil->parse($swissNumberStr, "CH");
    var_dump($swissNumberProto);
} catch (\libphonenumber\NumberParseException $e) {
    var_dump($e);
}

At this point, swissNumberProto contains:

class libphonenumber\PhoneNumber#9 (7) {
 private $countryCode =>
  int(41)
 private $nationalNumber =>
  double(446681800)
 private $extension =>
  NULL
 private $italianLeadingZero =>
  NULL
 private $rawInput =>
  NULL
 private $countryCodeSource =>
  NULL
 private $preferredDomesticCarrierCode =>
  NULL
}

Now let us validate whether the number is valid:

$isValid = $phoneUtil->isValidNumber($swissNumberProto);
var_dump($isValid); // true

There are a few formats supported by the formatting method, as illustrated below:

// Produces "+41446681800"
echo $phoneUtil->format($swissNumberProto, \libphonenumber\PhoneNumberFormat::E164);

// Produces "044 668 18 00"
echo $phoneUtil->format($swissNumberProto, \libphonenumber\PhoneNumberFormat::NATIONAL);

// Produces "+41 44 668 18 00"
echo $phoneUtil->format($swissNumberProto, \libphonenumber\PhoneNumberFormat::INTERNATIONAL);

You could also choose to format the number in the way it is dialled from another country:

// Produces "011 41 44 668 1800", the number when it is dialled in the United States.
echo $phoneUtil->formatOutOfCountryCallingNumber($swissNumberProto, "US");

// Produces "00 41 44 668 18 00", the number when it is dialled in Great Britain.
echo $phoneUtil->formatOutOfCountryCallingNumber($swissNumberProto, "GB");

Geocoder

$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();

$swissNumberProto = $phoneUtil->parse("044 668 18 00", "CH");
$usNumberProto = $phoneUtil->parse("+1 650 253 0000", "US");
$gbNumberProto = $phoneUtil->parse("0161 496 0000", "GB");

$geocoder = \libphonenumber\geocoding\PhoneNumberOfflineGeocoder::getInstance();

// Outputs "Zurich"
echo $geocoder->getDescriptionForNumber($swissNumberProto, "en_US");

// Outputs "Zürich"
echo $geocoder->getDescriptionForNumber($swissNumberProto, "de_DE");

// Outputs "Zurigo"
echo $geocoder->getDescriptionForNumber($swissNumberProto, "it_IT");

// Outputs "Mountain View, CA"
echo $geocoder->getDescriptionForNumber($usNumberProto, "en_US");

// Outputs "Mountain View, CA"
echo $geocoder->getDescriptionForNumber($usNumberProto, "de_DE");

// Outputs "미국" (Korean for United States)
echo $geocoder->getDescriptionForNumber($usNumberProto, "ko-KR");

// Outputs "Manchester"
echo $geocoder->getDescriptionForNumber($gbNumberProto, "en_GB");

// Outputs "영국" (Korean for United Kingdom)
echo $geocoder->getDescriptionForNumber($gbNumberProto, "ko-KR");

ShortNumberInfo

$shortNumberInfo = \libphonenumber\ShortNumberInfo::getInstance();

// true
var_dump($shortNumberInfo->isEmergencyNumber("999", "GB"));

// true
var_dump($shortNumberInfo->connectsToEmergencyNumber("999", "GB"));

// false
var_dump($shortNumberInfo->connectsToEmergencyNumber("911", "GB"));

// true
var_dump($shortNumberInfo->isEmergencyNumber("911", "US"));

// true
var_dump($shortNumberInfo->connectsToEmergencyNumber("911", "US"));

// false
var_dump($shortNumberInfo->isEmergencyNumber("911123", "US"));

// true
var_dump($shortNumberInfo->connectsToEmergencyNumber("911123", "US"));

Mapping Phone Numbers to carrier

$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
$swissNumberProto = $phoneUtil->parse("798765432", "CH");

$carrierMapper = \libphonenumber\PhoneNumberToCarrierMapper::getInstance();
// Outputs "Swisscom"
echo $carrierMapper->getNameForNumber($swissNumberProto, "en");

Mapping Phone Numbers to TimeZones

$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
$swissNumberProto = $phoneUtil->parse("798765432", "CH");

$timeZoneMapper = \libphonenumber\PhoneNumberToTimeZonesMapper::getInstance();
// returns array("Europe/Zurich")
$timeZones = $timeZoneMapper->getTimeZonesForNumber($swissNumberProto);

FAQ

Problems with Invalid Numbers?

This library uses phone number metadata from Google's libphonenumber. If this library is working as intended, it should provide the same result as the Java version of Google's project.

If you believe that a phone number is returning an incorrect result, first test it with libphonenumber via their Online Demo. If that returns the same result as this project, and you feel it is in error, raise it as an Issue with the libphonenumber project.

If Google's Online Demo gives a different result to the libphonenumber-for-php demo, then please raise an Issue here.

Generating data

Generating the data is not normally needed, as this repository will generally always have the up to data metadata.

If you do need to generate the data, the commands are provided by Phing. Ensure you have all the dev composer dependencies installed, then run

$ vendor/bin/phing compile

This compile process clones the libphonenumber project at the version specified in METADATA-VERSION.txt.

Running tests

This project uses PHPUnit Bridge to maintain compatibility for the supported PHP versions.

To run the tests locally, run the ./phpunit script.

Integration with frameworks

Other packages exist that integrate libphonenumber-for-php into frameworks.

Framework Packages
Symfony PhoneNumberBundle
Laravel Laravel Phone
Yii2 PhoneInput
Kohana PhoneNumber
TYPO3 TYPO3 Phone Extension

These packages are supplied by third parties, and their quality can not be guaranteed.

Comments
  • iranian phone number not valid?

    iranian phone number not valid?

    https://mobilebnk.com/hamrahe-aval/

    phone number like +98993XXXXXXX and +98994XXXXXXX should be valid. and this libraray say this number is not valid: +989934XXXXXX

    All number start with +98994XXXXXXX +98993XXXXXXX should be valid.

    metadata 
    opened by hooman-mirghasemi 24
  • The problem with the Chinese phone numbers.

    The problem with the Chinese phone numbers.

    Hello everybody. I get some problems with en/86.php. This file is too big compare with others (4,8Mb). So, I must spend big amount of valuable memory (almost 75Mb) when use geocoding for Chinese phone numbers. When I add necessary size of memory by ini_set (although it is not good) I anyway get problems with geocoding some numbers. For example I try use geocoding for 86-157-9662-1289. Actualy there is no such number and I should get empty result, instead I get fatal error, because it is need even more memory. Why that, I don't no. Anybody knows how to resolve this problem with memory wasting? May be should split the file 86.php into smaller files. Please, help me.

    bug 
    opened by olegsklyarov72 17
  • Unable to parse number with leading zero in phone number

    Unable to parse number with leading zero in phone number

    When I tried to parse +22505855515, I get following result

    PhoneNumber {#255
      #countryCode: 225
      #nationalNumber: "5855515"
      #extension: null
      #italianLeadingZero: true
      #rawInput: null
      #countryCodeSource: 4
      #preferredDomesticCarrierCode: null
      #hasNumberOfLeadingZeros: false
      #numberOfLeadingZeros: 1
    }
    

    In above result Leading zero is removed... If I use numberOfLeadingZeros then this is causing issue for other numbers.

    question 
    opened by sujit-baniya 15
  • PHP keyword static used as a new object

    PHP keyword static used as a new object

    My ide or Adobe CS5.5 Dreamweaver indicating the following line consists of an error: See package: /libphonenumber-for-php/src/PhoneNumberToCarrierMapper.php Line 51 , “static::$instance[$mappingDir] = new static($mappingDir);” Is that meant to be, or is it a bug?

    opened by rocbar 14
  • Use giggsey/Locale instead of relying on the intl extension

    Use giggsey/Locale instead of relying on the intl extension

    Remove the dependency on the intl extension, and instead use giggsey/Locale which has the latest CLDR data.

    It's a separate project so that they can be updated independently (CLDR releases seem to happen twice a year, libphonenumber releases about every month).

    There have been suggestions in the past to use symfony/intl, but this only provides English data.

    References: #43, #45, #46 (18 months later than originally planned).

    Todo:

    • [ ] Tidy up giggsey/Locale (README etc.) and tag a stable release
    • [ ] Decide what version this should be introduced in? Should this count as BC breaking?
    opened by giggsey 14
  • Missing leading zero CI national phone number ?

    Missing leading zero CI national phone number ?

    Hello, We are experiencing a problem with Ivory Coast mobile numbers. The leading zero is required for both national and international dialing and this is correctly handled by the library when using the format() method. Don't you think that in such a situation, the number returned by the getNationalNumber() method should include the leading zero? (which is not currently the case). Example: https://giggsey.com/libphonenumber/index.php?phonenumber=0789881234&country=CI Many thanks in advance for your reply.

    opened by Fly06-Fr 11
  • Getting empty object

    Getting empty object

            $phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance();
            $phoneNumberObject = $phoneNumberUtil->parse('0117 496 0123', 'GB');
    
            return $phoneNumberObject;
    

    I always getting a empty object.

    opened by ghost 11
  • A way to get area/carrier code and phone number by themselves

    A way to get area/carrier code and phone number by themselves

    Hi, There is \libphonenumber\PhoneNumber::getCountryCode() for retrieving country codes, but no such methods for area/carrier code or the number itself (without country and carrier codes). Are there any other ways to accomplish that?

    question 
    opened by ArtemGordinsky 11
  • [Help] How to invalidate number

    [Help] How to invalidate number

    Hi!

    I am probably doing something wrong, but I have issue to in/validate phone numbers.

    Here is a short example:

    function tphValidate($p)
    {
    	$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
    	$phoneInfo = $phoneUtil->parse($p, null);
    	$isValid = $phoneUtil->isValidNumber($phoneInfo);
    	return $isValid;
    }
    

    Will return "1" if the supplied $p is a valid E164 phone number, but won't return anything is $p is something else. What should I do to get a false?

    Many thanks for your help.

    question 
    opened by MrNonoss 10
  • +3371700**** This number showing invalid inspite of being a valid number

    +3371700**** This number showing invalid inspite of being a valid number

    Hello Team,

    we updated to latest tag 8.12.19, still +3371700**** This number showing invalid inspite of being a valid number.

    https://giggsey.com/libphonenumber/index.php?phonenumber=%2B33+717001974&country=FR&language=&region=

    metadata 
    opened by VivekBisht21 10
  • getAsYouTypeFormatter missing

    getAsYouTypeFormatter missing

    Hello ! I saw that the getAsYouTypeFormatter functionality is missing from your package. :( It is present it the official Google library (v7.1.0).

    Can you please implement it?

    I am refering to this: Formatting Phone Numbers 'as you type'

    PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); AsYouTypeFormatter formatter = phoneUtil.getAsYouTypeFormatter("US"); System.out.println(formatter.inputDigit('6')); // Outputs "6" ... // Input more digits System.out.println(formatter.inputDigit('3')); // Now outputs "650 253"

    enhancement 
    opened by vladrusu 10
  • Latest releases stop parsing some phone numbers

    Latest releases stop parsing some phone numbers

    Hey there! We have updated to the latest version and got issues with some phone numbers. For example, CI phone numbers (+225) You can check it on 22558583937 \libphonenumber\PhoneNumberUtil::isPossibleNumber() returns false, but phone is correct and it's works on 8.12.17 version.

    opened by KiPa187 1
  • tests failing with `phpunit` - fatal error for syntax issues?

    tests failing with `phpunit` - fatal error for syntax issues?

    Hello,

    I know one should use ./phpunit (hence simple-phpunit) for the tests, but actually I don't have the possibility to use it, so I run the tests by executing phpunit. I can't use simple-phpunit because that script it is not packaged in Debian and it is likely it won't be. I need to run the test because I'm trying to package your lib into an official Debian package, and we are strongly advised to run upstream's test suite in the package.

    Running phpunit returns this error

    PHP Fatal error:  Declaration of libphonenumber\Tests\Issues\CodeCoverageTest::setUp() must be compatible with PHPUnit\Framework\TestCase::setUp(): void in php-giggsey-libphonenumber/tests/Issues/CodeCoverageTest.php on line 16
    PHP Stack trace:
    PHP   1. {main}() /usr/bin/phpunit:0
    PHP   2. PHPUnit\TextUI\Command::main($exit = *uninitialized*) /usr/bin/phpunit:42
    PHP   3. PHPUnit\TextUI\Command->run($argv = [0 => '/usr/bin/phpunit'], $exit = TRUE) /usr/share/php/PHPUnit/TextUI/Command.php:95
    PHP   4. PHPUnit\TextUI\Command->handleArguments($argv = [0 => '/usr/bin/phpunit']) /usr/share/php/PHPUnit/TextUI/Command.php:110
    PHP   5. PHPUnit\TextUI\TestSuiteMapper->map($configuration = class PHPUnit\TextUI\XmlConfiguration\TestSuiteCollection { private $testSuites = [0 => class PHPUnit\TextUI\XmlConfiguration\TestSuite { ... }] }, $filter = '') /usr/share/php/PHPUnit/TextUI/Command.php:389
    PHP   6. PHPUnit\Framework\TestSuite->addTestFiles($fileNames = [0 => 'php-giggsey-libphonenumber/tests/Issues/CodeCoverageTest.php', 1 => 'php-giggsey-libphonenumber/tests/Issues/Issue106Test.php', 2 => 'php-giggsey-libphonenumber/tests/Issues/Issue135Test.php', 3 => 'php-giggsey-libphonenumber/tests/Issues/Issue14Test.php', 4 => 'php-giggsey-libphonenumber/tests/Issues/Issue152Test.php', 5 => 'php-giggsey-libphonenumber/tests/Issues/Issue159Test.php', 6 => 'php-giggsey-libphonenumber/tests/Issues/Issue175Test.php', 7 => 'php-giggsey-libphonenumber/tests/Issues/Issue17Test.php', 8 => 'php-giggsey-libphonenumber/tests/Issues/Issue21Test.php', 9 => 'php-giggsey-libphonenumber/tests/Issues/Issue23Test.php', 10 => 'php-giggsey-libphonenumber/tests/Issues/Issue34Test.php', 11 => 'php-giggsey-libphonenumber/tests/Issues/Issue35Test.php', 12 => 'php-giggsey-libphonenumber/tests/Issues/Issue360Test.php', 13 => 'php-giggsey-libphonenumber/tests/Issues/Issue36Test.php', 14 => 'php-giggsey-libphonenumber/tests/Issues/Issue3Test.php', 15 => 'php-giggsey-libphonenumber/tests/Issues/Issue44Test.php', 16 => 'php-giggsey-libphonenumber/tests/Issues/Issue4Test.php', 17 => 'php-giggsey-libphonenumber/tests/Issues/Issue64Test.php', 18 => 'php-giggsey-libphonenumber/tests/Issues/Issue68Test.php', 19 => 'php-giggsey-libphonenumber/tests/Issues/Issue76Test.php', 20 => 'php-giggsey-libphonenumber/tests/Issues/LocaleTest.php', 21 => 'php-giggsey-libphonenumber/tests/Issues/PHP7Test.php', 22 => 'php-giggsey-libphonenumber/tests/Issues/UKNumbersTest.php', 23 => 'php-giggsey-libphonenumber/tests/buildtools/BuildMetadataFromXmlTest.php', 24 => 'php-giggsey-libphonenumber/tests/buildtools/GeneratePhonePrefixDataTest.php', 25 => 'php-giggsey-libphonenumber/tests/buildtools/MetadataFilterTest.php', 26 => 'php-giggsey-libphonenumber/tests/carrier/PhoneNumberToCarrierMapperTest.php', 27 => 'php-giggsey-libphonenumber/tests/core/AsYouTypeFormatterTest.php', 28 => 'php-giggsey-libphonenumber/tests/core/ExampleNumbersTest.php', 29 => 'php-giggsey-libphonenumber/tests/core/MatcherTest.php', 30 => 'php-giggsey-libphonenumber/tests/core/MultiFileMetadataSourceImplTest.php', 31 => 'php-giggsey-libphonenumber/tests/core/PhoneMetadataTest.php', 32 => 'php-giggsey-libphonenumber/tests/core/PhoneNumberMatchTest.php', 33 => 'php-giggsey-libphonenumber/tests/core/PhoneNumberMatcherTest.php', 34 => 'php-giggsey-libphonenumber/tests/core/PhoneNumberTest.php', 35 => 'php-giggsey-libphonenumber/tests/core/PhoneNumberUtilTest.php', 36 => 'php-giggsey-libphonenumber/tests/core/ShortNumberInfoTest.php', 37 => 'php-giggsey-libphonenumber/tests/geocoding/PhoneNumberOfflineGeocoderTest.php', 38 => 'php-giggsey-libphonenumber/tests/prefixmapper/PrefixFileReaderTest.php', 39 => 'php-giggsey-libphonenumber/tests/timezone/PrefixTimeZonesMapTest.php', 40 => 'php-giggsey-libphonenumber/tests/timezone/UKTest.php']) /usr/share/php/PHPUnit/TextUI/TestSuiteMapper.php:67
    PHP   7. PHPUnit\Framework\TestSuite->addTestFile($filename = 'php-giggsey-libphonenumber/tests/Issues/CodeCoverageTest.php') /usr/share/php/PHPUnit/Framework/TestSuite.php:530
    PHP   8. PHPUnit\Util\FileLoader::checkAndLoad($filename = 'php-giggsey-libphonenumber/tests/Issues/CodeCoverageTest.php') /usr/share/php/PHPUnit/Framework/TestSuite.php:402
    PHP   9. PHPUnit\Util\FileLoader::load($filename = 'php-giggsey-libphonenumber/tests/Issues/CodeCoverageTest.php') /usr/share/php/PHPUnit/Util/FileLoader.php:49
    PHP  10. include_once() /usr/share/php/PHPUnit/Util/FileLoader.php:65
    
    

    Would you fix your tests so that they also work with phpunit?

    phpunit --version
    PHPUnit 9.5.2 by Sebastian Bergmann and contributors.
    
    opened by tenzap 20
  • Method maybeExtractCountryCode very slowly

    Method maybeExtractCountryCode very slowly

    $ composer show giggsey/libphonenumber-for-php
    
    name     : giggsey/libphonenumber-for-php
    descrip. : PHP Port of Google's libphonenumber
    keywords : geocoding, geolocation, libphonenumber, mobile, phonenumber, validation
    versions : * 8.12.19
    
    php -v
    
    PHP 7.4.3 (cli) (built: Feb 20 2020 21:53:46) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
        with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
        with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
    

    callgraph callgraph (1) callgraph (2)

    Maybe need add mechanism for cache of parsing? How I can cache or serialize phonenumber phone for cache?

    help wanted 
    opened by anboo 3
  • Make use of giggsey/locale opt-in

    Make use of giggsey/locale opt-in

    While I understand the rationale behind #119 ,giggsey/locale dependency could lead to inconsistency for people which are already using the intl extension, and is useless for people which have up-to-date ICU.

    As such I think you could add giggsey/locale (and ext-intl) in the suggest composer section and make the Locale class a variable (don't know how to do this properly though).

    WDYT?

    question 
    opened by MatTheCat 10
Releases(8.13.3)
  • 8.13.3(Dec 22, 2022)

    Google v8.13.3 changes: Dec 21, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): 882, 883, AT, GP, MX, QA, RE, SG, YE
    • Updated short number metadata for region code(s): AT, BE
    • Updated geocoding data for country calling code(s): 52 (en)
    • Updated carrier data for country calling code(s): 44 (en), 65 (en), 420 (en), 882 (en), 967 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.13.2(Dec 8, 2022)

    Google v8.13.2 changes: Dec 07, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): 882, AS, AU, BI, BM, BS, CA, CC, CX, ET, GB, GH, GU, GY, MK, MU, NG, SG, SO, TJ, US, UY, VI
    • New geocoding data for country calling code(s): 1350 (en), 1354 (en), 1382 (en), 1683 (en), 1835 (en)
    • Updated geocoding data for country calling code(s): 1340 (en)
    • Updated carrier data for country calling code(s): 27 (en), 33 (en), 61 (en), 65 (en), 230 (en), 233 (en), 234 (en), 252 (en), 260 (en), 370 (en), 592 (en), 882 (en), 992 (en), 1441 (en), 1671 (en)
    • Updated / refreshed time zone meta data.
    Source code(tar.gz)
    Source code(zip)
  • 8.13.1(Nov 28, 2022)

    Google v8.13.1 changes: Nov 10, 2022

    Metadata changes:
    • Updated alternate formatting data for country calling code(s): 7
    • Updated phone metadata for region code(s): GI, KG, KZ, RU
    • Updated geocoding data for country calling code(s): 7 (en, ru), 64 (en)
    • Updated carrier data for country calling code(s): 51 (en), 350 (en), 420 (en), 996 (en)
    • Updated / refreshed time zone meta data.

    giggsey/libphonenumber-for-php-lite

    If you only want to make use of the core PhoneNumber Util functionality, you can use giggsey/libphonenumber-for-php-lite, which offers a much smaller package size.

    Source code(tar.gz)
    Source code(zip)
  • 8.13.0(Nov 7, 2022)

    Google v8.13.0 changes: Oct 28, 2022

    Code changes:
    • Removal of unused leading_zero_possible
    Metadata changes:
    • Updated phone metadata for region code(s): 883, BW, CI, CN, CY, HN, MA, MK, MV, OM
    • Updated short number metadata for region code(s): FI
    • Updated geocoding data for country calling code(s): 504 (en)
    • Updated carrier data for country calling code(s): 7 (en, ru), 46 (en), 47 (en), 48 (en), 357 (en), 359 (en), 389 (en), 960 (en)

    PHP Changes

    • Region Code is now case insensitive in more places (#541)

    giggsey/libphonenumber-for-php-lite

    If you only want to make sure of the core PhoneNumber Util functionality, you can use giggsey/libphonenumber-for-php-lite, which offers a much smaller package size.

    Source code(tar.gz)
    Source code(zip)
  • 8.12.57(Oct 14, 2022)

    Google v8.12.57 changes: Oct 11, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): BJ, EH, GB, GF, GG, JE, MA, MW, SG, SN, SO, ZM
    • Updated geocoding data for country calling code(s): 229 (en)
    • Updated carrier data for country calling code(s): 27 (en), 34 (en), 47 (en), 65 (en), 212 (en), 252 (en), 260 (en), 594 (en), 974 (en)
    • Updated / refreshed time zone meta data.

    PHP Changes

    • isValidRegionCode() is now case insensitive (#534 - thanks @greew)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.56(Sep 23, 2022)

    Google v8.12.56 changes: Sep 22, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): HR, MK, PT, SG, TT
    • Updated short number metadata for region code(s): BZ
    • Updated carrier data for country calling code(s): 31 (en), 65 (en), 385 (en), 389 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.55(Sep 9, 2022)

    Google v8.12.55 changes: Sep 08, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): AU, CA, CC, CI, CO, CX, DE, HK, KW, LV, MV, PA, PL, TZ, US
    • Updated short number metadata for region code(s): CO, TZ
    • New geocoding data for country calling code(s): 1742 (en), 1753 (en)
    • Updated geocoding data for country calling code(s): 57 (en), 225 (en), 960 (en)
    • New carrier data for country calling code(s): 371 (en)
    • Updated carrier data for country calling code(s): 47 (en), 57 (en), 61 (en), 90 (en), 255 (en), 297 (en), 381 (en), 420 (en), 972 (en), 974 (en)
    • Updated / refreshed time zone meta data.
    Source code(tar.gz)
    Source code(zip)
  • 8.12.54(Aug 22, 2022)

    Google v8.12.54 changes: Aug 18, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): BE, BF, GE, HN, MX, PT, US
    • Updated geocoding data for country calling code(s): 52 (en), 61 (en), 351 (en)
    • Updated carrier data for country calling code(s): 226 (en), 351 (en), 420 (en), 992 (en), 995 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.53(Aug 8, 2022)

    Google v8.12.53 changes: Aug 04, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): AT, BE, CL, CN, GE, GF, GH, HK, JM, PG, RE, US
    • Updated short number metadata for region code(s): AT
    • New geocoding data for country calling code(s): 1943 (en)
    • Updated carrier data for country calling code(s): 34 (en), 56 (en), 57 (en), 86 (en), 233 (en), 972 (en), 992 (en)
    • Updated / refreshed time zone meta data.
    Source code(tar.gz)
    Source code(zip)
  • 8.12.52(Jul 20, 2022)

    Google v8.12.52 changes: Jul 19, 2022

    Metadata changes:
    • Updated alternate formatting data for country calling code(s): 49
    • Updated phone metadata for region code(s): BW, DE, ET, HK, ML, MN, MQ, NP, PE, QA, SG
    • Updated geocoding data for country calling code(s): 61 (en)
    • Updated carrier data for country calling code(s): 48 (en), 65 (en), 223 (en), 251 (en), 852 (en, zh), 976 (en), 977 (en)
    • Updated / refreshed time zone meta data.
    Source code(tar.gz)
    Source code(zip)
  • 8.12.51(Jul 11, 2022)

    Google v8.12.51 changes: Jun 28, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): 800, BJ, BR, CO, EH, FO, GE, GP, KE, KG, MA, MM, MN, MY, NZ, RE, SI, UG, VN
    • Updated geocoding data for country calling code(s): 57 (en), 61 (en)
    • Updated carrier data for country calling code(s): 60 (en), 254 (en), 262 (en), 298 (en), 386 (en), 421 (en), 976 (en), 995 (en), 996 (en)
    • Updated / refreshed time zone meta data.
    Source code(tar.gz)
    Source code(zip)
  • 8.12.50(Jun 9, 2022)

    Google v8.12.50 changes: Jun 09, 2022

    Metadata changes:
    • Updated alternate formatting data for country calling code(s): 380, 49
    • Updated phone metadata for region code(s): AR, CL, DE, EH, GB, HK, HR, IR, IT, MA, MH, TT, UA, US
    • New geocoding data for country calling code(s): 1826 (en)
    • Updated geocoding data for country calling code(s): 34 (en, es), 54 (en), 61 (en)
    • Updated carrier data for country calling code(s): 44 (en), 98 (en, fa), 212 (en), 380 (en, uk), 385 (en), 420 (en), 852 (en, zh)
    • Updated / refreshed time zone meta data.
    Source code(tar.gz)
    Source code(zip)
  • 8.12.49(May 27, 2022)

    Google v8.12.49 changes: May 25, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): CA, CM, GB, IL, JM, JP, MA, MV, PG, US
    • Updated geocoding data for country calling code(s): 33 (en), 44 (en), 212 (en, fr), 1310 (en)
    • Updated carrier data for country calling code(s): 237 (en), 675 (en)
    • Updated / refreshed time zone meta data.
    Source code(tar.gz)
    Source code(zip)
  • 8.12.48(May 6, 2022)

    Google v8.12.48 changes: May 05, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): AG, AI, AS, BB, BM, BR, BS, CA, DM, DO, EE, GD, GF, GP, GU, IS, JM, KN, KY, LC, MN, MP, MS, NL, NP, PM, PR, SI, SX, SY, TC, TT, UG, US, VC, VG, VI, YT
    • New geocoding data for country calling code(s): 1263 (en), 1468 (en), 1584 (en), 1656 (en), 1948 (en)
    • Updated carrier data for country calling code(s): 354 (en), 370 (en), 372 (en), 503 (en), 963 (en), 977 (en)
    • Updated / refreshed time zone meta data.
    Source code(tar.gz)
    Source code(zip)
  • 8.12.47.1(Apr 25, 2022)

    8.12.47.1 vs 8.12.47

    Google re-released 8.12.47 due to an error during their tagging system. Due to the time difference between the two releases, the underlying metadata actually changed.

    The release notes below are the updated release notes across both releases.

    Google v8.12.47 changes: Apr 19, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): AO, BB, FR, GB, GE, GG, HR, JE, MT, NC, PA, SE
    • Updated carrier data for country calling code(s): 33 (en), 41 (en), 46 (en), 244 (en), 351 (en), 385 (en), 420 (en), 974 (en), 995 (en), 1246 (en), 1345 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.47(Apr 19, 2022)

    Google v8.12.47 changes: Apr 14, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): FR, GB, GE, GG, HR, JE, MT, NC, PA, SE
    • Updated carrier data for country calling code(s): 33 (en), 41 (en), 46 (en), 351 (en), 385 (en), 420 (en), 974 (en), 995 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.46(Mar 31, 2022)

    Google v8.12.46 changes: Mar 31, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): BJ, JM, PW, SA
    • Updated short number metadata for region code(s): HU
    • Updated carrier data for country calling code(s): 36 (en), 51 (en), 61 (en), 90 (en), 229 (en), 254 (en), 680 (en), 966 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.45(Mar 10, 2022)

    Google v8.12.45 changes: Mar 10, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): BF, EE, JM, RE, SE, US
    • New geocoding data for country calling code(s): 1464 (en)
    • Updated carrier data for country calling code(s): 46 (en), 55 (en), 226 (en), 262 (en), 353 (en), 372 (en), 373 (en), 1345 (en)
    • Updated / refreshed time zone meta data.
    Source code(tar.gz)
    Source code(zip)
  • 8.12.44(Feb 24, 2022)

    Google v8.12.44 changes: Feb 23, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): AG, AI, AS, BB, BM, BS, CA, CV, DM, DO, GD, GU, JM, KN, KY, LC, MP, MS, PR, SC, SX, TC, TT, US, VC, VG, VI
    • Updated short number metadata for region code(s): BE, PT, SC, SE, US
    • Updated geocoding data for country calling code(s): 61 (en), 238 (en), 1345 (en)
    • Updated carrier data for country calling code(s): 238 (en), 248 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.43(Feb 9, 2022)

    Google v8.12.43 changes: Feb 09, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): BJ, CL, GA, IS, KR, KW, LI, PA, SG, SL
    • Updated short number metadata for region code(s): MS
    • Updated geocoding data for country calling code(s): 56 (en, es)
    • Updated carrier data for country calling code(s): 32 (en), 229 (en), 354 (en), 502 (en), 507 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.42(Jan 28, 2022)

    Google v8.12.42 changes: Jan 27, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): BG, BI, CF, DZ, GF, GP, HK, IR, MA, MQ, MW, PK, PL, PM, QA, TJ
    • Updated short number metadata for region code(s): AG, AI, AS, BB, BM, BS, CA, DM, DO, GD, GU, JM, KN, KY, LC, MP, MS, PR, SX, TC, TT, US, VC, VG, VI
    • Updated geocoding data for country calling code(s): 61 (en), 213 (en)
    • Updated carrier data for country calling code(s): 45 (en), 48 (en), 57 (en), 98 (en, fa), 236 (en), 243 (en), 257 (en), 420 (en), 421 (en), 508 (en), 675 (en), 852 (en, zh), 974 (en), 992 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.41(Jan 11, 2022)

    Google v8.12.41 changes: Jan 11, 2022

    Metadata changes:
    • Updated phone metadata for region code(s): EH, IL, KE, LA, MA, OM, SG
    • Updated short number metadata for region code(s): PY
    • Updated carrier data for country calling code(s): 33 (en), 65 (en), 358 (en), 383 (en), 420 (en), 502 (en), 856 (en), 966 (en), 968 (en), 974 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.40(Dec 23, 2021)

    Google v8.12.40 changes: Dec 23, 2021

    Metadata changes:
    • Updated phone metadata for region code(s): GP, GY, MK, VU
    • Updated geocoding data for country calling code(s): 389 (en)
    • Updated carrier data for country calling code(s): 60 (en), 592 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.39(Dec 7, 2021)

    Google v8.12.39 changes: Dec 07, 2021

    Metadata changes:
    • Updated phone metadata for region code(s): CO, EH, HK, MA, MU, ZM
    • Updated carrier data for country calling code(s): 57 (en), 81 (en), 852 (en, zh)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.38(Nov 26, 2021)

    Google v8.12.38 changes: Nov 25, 2021

    Metadata changes:
    • Updated phone metadata for region code(s): 883, AT, BI, BW, CG, EE, EH, HN, HU, LI, LK, MA, PA, PH, SG, TH, TJ
    • Updated geocoding data for country calling code(s): 61 (en), 504 (en)
    • Updated carrier data for country calling code(s): 51 (en), 65 (en), 370 (en), 992 (en)
    • Updated / refreshed time zone meta data.
    Source code(tar.gz)
    Source code(zip)
  • 8.12.37(Nov 11, 2021)

    Google v8.12.37 changes: Nov 11, 2021

    Metadata changes:
    • Updated phone metadata for region code(s): AU, BD, CC, CX, GB, IT, LI, MQ, SG, US, VA
    • Updated geocoding data for country calling code(s): 880 (en)
    • Updated carrier data for country calling code(s): 65 (en), 81 (en), 356 (en), 423 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.36(Oct 26, 2021)

    Google v8.12.36 changes: Oct 26, 2021

    Metadata changes:
    • Updated phone metadata for region code(s): AZ, GA, HK, JM, KW, RO, TJ, UY
    • Updated geocoding data for country calling code(s): 994 (en)
    • Updated carrier data for country calling code(s): 40 (en), 41 (en), 252 (en), 852 (en, zh), 965 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.35(Oct 12, 2021)

    Google v8.12.35 changes: Oct 12, 2021

    Metadata changes:
    • Updated phone metadata for region code(s): AU, AZ, CC, CO, CX, EH, HN, MA
    • Updated carrier data for country calling code(s): 994 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.34(Oct 6, 2021)

    PHP changes

    • Support for PHP 8.1

    Google v8.12.34 changes: Oct 06, 2021

    Metadata changes:
    • Updated phone metadata for region code(s): AR, BD, DE, MX, VI
    • Updated geocoding data for country calling code(s): 55 (en), 420 (en), 880 (en), 1340 (en)
    Source code(tar.gz)
    Source code(zip)
  • 8.12.33(Sep 22, 2021)

    Google v8.12.33 changes: Sep 22, 2021

    Metadata changes:
    • Updated phone metadata for region code(s): CG, CZ, GE, GF, GR, KR, MT, PA, TH, UG, UZ
    • Updated geocoding data for country calling code(s): 420 (en)
    • Updated carrier data for country calling code(s): 46 (en), 420 (en), 966 (en)
    Source code(tar.gz)
    Source code(zip)
Arbitrary number base converter.

Numbase Easily convert numbers between arbitrary bases and symbol sets. Installation This library is available on Packagist as thunderer/numbase. It r

Tomasz Kowalczyk 23 Sep 25, 2022
A PHP 5.3+ mathematics library, providing functionality for large numbers

Moontoast Math Library Moontoast\Math is useful for working with integers that are larger than (or may become larger than, through mathematical comput

Moontoast 245 Sep 8, 2022
Advanced Mathematics Library for PHP (port of Numbers.js)

Numbers.php Numbers.php - an advanced mathematics toolkit for PHP >= 5.3. It is a port of Numbers.js - same toolkit for JavaScript. There is a version

null 159 Jul 24, 2022
Library for converting units and sizes in PHP

php-conversion Library for converting units and sizes in PHP. Units supported Acceleration Angle Area Digital information Electric current Frequency F

Christoffer Niska 127 Dec 23, 2022
BigNum library for PHP compatible with bn.js

BigNum library for PHP Information This library provides a PHP Big Number API compatible with bn.js and is used in Fast PHP ECC library elliptic-php.

Simplito 16 Nov 13, 2022
Library for converting units and sizes in PHP

php-conversion Library for converting units and sizes in PHP. Units supported Acceleration Angle Area Digital information Electric current Frequency F

Christoffer Niska 122 Mar 16, 2021
Mark Rogoyski 2.2k Dec 29, 2022
Arbitrary-precision arithmetic library for PHP

Arbitrary-precision arithmetic library for PHP

Brick 1.4k Jan 1, 2023
Tensor is a library and extension that provides objects for scientific computing in PHP.

Tensor is a library and extension that provides objects for scientific computing in PHP. The multithreaded extension is especially suited for computing large sets of numbers. In some cases, the extension is 230X faster than the same operation in PHPland. Tensor is used by libraries such as Rubix ML to build and accelerate machine learning algorithms such as linear regression, dimensionality reduction, and neural networks.

Rubix 157 Jan 3, 2023
Library to parse, format and convert byte units

Byte Units This is a utility component for parsing, formatting, converting and manipulating byte units in various formats. Usage <?php // Bytes manip

Gabriele Lana 156 Dec 9, 2022
Unit converter and calculator for php

Unit converter and calculator This library uses the awesome lisachenko/z-engine to allow mathematical operations on objects, allowing to do stuff like

Dominik Chrástecký 8 Apr 8, 2022
Version is a library that helps with managing the version number of Git-hosted PHP projects

Version Version is a library that helps with managing the version number of Git-hosted PHP projects. Installation You can add this library as a local,

Sebastian Bergmann 6.3k Dec 26, 2022
Adds phone number functionality to Laravel based on the PHP port of Google's libphonenumber API by giggsey.

Laravel Phone Adds phone number functionality to Laravel based on the PHP port of Google's libphonenumber API by giggsey. Table of Contents Demo Insta

null 2.1k Jan 2, 2023
Adds phone number functionality to TYPO3 based on the PHP port of Google's libphonenumber API by giggsey

TYPO3 Phone Adds phone number functionality to TYPO3 based on the PHP port of Google's libphonenumber API by giggsey. Installation composer require si

Simon Schaufelberger 3 Oct 25, 2022
Phone number functionality for Laravel

Laravel Phone Adds phone number functionality to Laravel and Lumen based on the PHP port of Google's libphonenumber API by giggsey. Table of Contents

null 2.1k Dec 31, 2022
Laravel Dutch Phone Number Validator

Laravel Dutch Phone Number Validator Validate if the given phone number is a valid Dutch phone number Table of Contents Installation Usage Translation

Tim Wassenburg 0 May 30, 2022
This package is used to validate the telephone numbers of the countries taken into account. It also makes it possible to verify that a number is indeed a number of an operator X

phone-number-checker This package is used to validate the telephone numbers of the countries taken into account. It also makes it possible to verify t

faso-dev 4 Feb 7, 2022
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way. ( WEBSITE VERSION )

Mysql Optimizer mysql optimizer also known as MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query

null 3 Feb 14, 2022
PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Manufacturing Industry, Phone numbers & Zipcodes for many countries

IsoCodes PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Book Industry, Phone numbers & Zipcodes

Ronan Guilloux 767 Jan 2, 2023
The Current US Version of PHP-Nuke Evolution Xtreme v3.0.1b-beta often known as Nuke-Evolution Xtreme. This is a hardened version of PHP-Nuke and is secure and safe. We are currently porting Xtreme over to PHP 8.0.3

2021 Nightly Builds Repository PHP-Nuke Evolution Xtreme Developers TheGhost - Ernest Allen Buffington (Lead Developer) SeaBeast08 - Sebastian Scott B

Ernest Buffington 7 Aug 28, 2022