Skip to content

giggsey/libphonenumber-geocoder

Repository files navigation

libphonenumber's Geocoder for PHP Build Status

Total Downloads Latest Stable Version

This Project has been merged into giggsey/libphonenumber-for-php. Please use that for all further updates

What is it?

A PHP library for providing geographical information for a phone number. This library is based on Google's libphonenumber and requires libphonenumber-for-php to work.

This library requires the PECL intl extension to be installed.

Installation

The library can be installed via composer. You can also use any other PSR-0 compliant autoloader.

{
    "require": {
        "giggsey/libphonenumber-geocoder": "~5.8"
    }
}

Online Demo

An online demo is available for both libphonenumber-for-php and libphonenumber-geocoder.

Examples

$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") . PHP_EOL;
// Outputs "Zürich"
echo $geocoder->getDescriptionForNumber($swissNumberProto, "de_DE") . PHP_EOL;
// Outputs "Zurigo"
echo $geocoder->getDescriptionForNumber($swissNumberProto, "it_IT") . PHP_EOL;


// Outputs "Mountain View, CA"
echo $geocoder->getDescriptionForNumber($usNumberProto, "en_US") . PHP_EOL;
// Outputs "Mountain View, CA"
echo $geocoder->getDescriptionForNumber($usNumberProto, "de_DE") . PHP_EOL;
// Outputs "미국" (Korean for United States)
echo $geocoder->getDescriptionForNumber($usNumberProto, "ko-KR") . PHP_EOL;

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

About

PHP Port of Google's libphonenumber geocoder

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages