{"id":32491943,"url":"https://github.com/giggsey/libphonenumber-for-php-lite","last_synced_at":"2026-04-02T21:31:29.010Z","repository":{"id":62368178,"uuid":"558902670","full_name":"giggsey/libphonenumber-for-php-lite","owner":"giggsey","description":"PHP version of Google's phone number handling library","archived":false,"fork":false,"pushed_at":"2026-01-15T12:04:10.000Z","size":17215,"stargazers_count":73,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-15T16:44:00.038Z","etag":null,"topics":["hacktoberfest","libphonenumber","phone-number","php"],"latest_commit_sha":null,"homepage":"https://giggsey.com/libphonenumber/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/giggsey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-10-28T14:57:06.000Z","updated_at":"2026-01-15T12:04:14.000Z","dependencies_parsed_at":"2024-02-08T15:51:36.180Z","dependency_job_id":"931a85de-1e69-4094-acfe-a8fdcafff265","html_url":"https://github.com/giggsey/libphonenumber-for-php-lite","commit_stats":{"total_commits":760,"total_committers":58,"mean_commits":13.10344827586207,"dds":0.2723684210526316,"last_synced_commit":"6170739285bf9d31a4d4a13a6055d94c8daec072"},"previous_names":[],"tags_count":78,"template":false,"template_full_name":null,"purl":"pkg:github/giggsey/libphonenumber-for-php-lite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giggsey%2Flibphonenumber-for-php-lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giggsey%2Flibphonenumber-for-php-lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giggsey%2Flibphonenumber-for-php-lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giggsey%2Flibphonenumber-for-php-lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giggsey","download_url":"https://codeload.github.com/giggsey/libphonenumber-for-php-lite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giggsey%2Flibphonenumber-for-php-lite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29857045,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T08:51:08.701Z","status":"ssl_error","status_checked_at":"2026-02-26T08:50:19.607Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","libphonenumber","phone-number","php"],"created_at":"2025-10-27T10:19:13.435Z","updated_at":"2026-04-02T21:31:29.002Z","avatar_url":"https://github.com/giggsey.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libphonenumber for PHP (Lite) [![Build Status](https://github.com/giggsey/libphonenumber-for-php-lite/workflows/Tests/badge.svg)](https://github.com/giggsey/libphonenumber-for-php-lite/actions?query=workflow%3A%22Tests%22) [![codecov](https://codecov.io/gh/giggsey/libphonenumber-for-php-lite/branch/main/graph/badge.svg?token=S0TV2TAXOQ)](https://codecov.io/gh/giggsey/libphonenumber-for-php-lite) [![Mutation testing badge](https://img.shields.io/endpoint?style=flat-square\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fgiggsey%2Flibphonenumber-for-php-lite%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/giggsey/libphonenumber-for-php-lite/main)\n\n\n[![Total Downloads](https://poser.pugx.org/giggsey/libphonenumber-for-php-lite/downloads?format=flat-square)](https://packagist.org/packages/giggsey/libphonenumber-for-php-lite)\n[![Downloads per month](https://img.shields.io/packagist/dm/giggsey/libphonenumber-for-php-lite.svg?style=flat-square)](https://packagist.org/packages/giggsey/libphonenumber-for-php-lite)\n[![Latest Stable Version](https://img.shields.io/packagist/v/giggsey/libphonenumber-for-php-lite.svg?style=flat-square)](https://packagist.org/packages/giggsey/libphonenumber-for-php-lite)\n[![License](https://img.shields.io/badge/license-Apache%202.0-red.svg?style=flat-square)](https://packagist.org/packages/giggsey/libphonenumber-for-php-lite)\n\n## What is it?\nA PHP library for parsing, formatting, storing and validating international phone numbers. This library is based on Google's [libphonenumber](https://github.com/google/libphonenumber).\n\nThis is a lite version that only includes the core Phone Number Utils. To make full use of the library, including geolocation, carrier information and short number info, use [giggsey/libphonenumber-for-php](https://github.com/giggsey/libphonenumber-for-php)\n\n - [Installation](#installation)\n - [Documentation](#documentation)\n - [Highlights of functionality](#highlights-of-functionality)\n   - [Versioning](#versioning)\n   - [Quick Examples](#quick-examples)\n - [FAQ](#faq)\n   - [Problems with Invalid Numbers?](#problems-with-invalid-numbers)\n - [Generating data](#generating-data)\n\n## Installation\n\nPHP versions 8.1 and above are supported.\n\nThe PECL [mbstring](http://php.net/mbstring) extension is required.\n\nIt is recommended to use [composer](https://getcomposer.org) to install the library.\n\n```bash\ncomposer require giggsey/libphonenumber-for-php-lite\n```\n\nYou can also use any other [PSR-4](http://www.php-fig.org/psr/psr-4/) compliant autoloader.\n\n### PHP Version Policy\n\nThis library will be updated to use [supported versions of PHP](https://www.php.net/supported-versions.php) only.\n\n## Documentation\n\n - [PhoneNumber Util](docs/PhoneNumberUtil.md)\n\n# Highlights of functionality\n* Parsing/formatting/validating phone numbers for all countries/regions of the world.\n* `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).\n* `isNumberMatch` - gets a confidence level on whether two numbers could be the same.\n* `getExampleNumber`/`getExampleNumberByType` - provides valid example numbers for all countries/regions, with the option of specifying which type of example phone number is needed.\n* `isValidNumber` - full validation of a phone number for a region using length and prefix information.\n\n## Versioning\n\nThis 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.\n\nThis does mean that this project may not follow [Semantic Versioning](http://semver.org/), but instead Google's version policy. As a result, jumps in major versions may not actually contain any backwards\nincompatible changes. Please read the release notes for such releases.\n\nGoogle try to release their versions according to Semantic Versioning, as laid out of in their [Versioning Guide](https://github.com/google/libphonenumber#versioning-and-announcements).\n\n## Quick Examples\nLet's say you have a string representing a phone number from Switzerland. This is how you parse/normalize it into a PhoneNumber object:\n\n```php\n$swissNumberStr = \"044 668 18 00\";\n$phoneUtil = \\libphonenumber\\PhoneNumberUtil::getInstance();\ntry {\n    $swissNumberProto = $phoneUtil-\u003eparse($swissNumberStr, \"CH\");\n    var_dump($swissNumberProto);\n} catch (\\libphonenumber\\NumberParseException $e) {\n    var_dump($e);\n}\n```\n\nAt this point, swissNumberProto contains:\n\n    class libphonenumber\\PhoneNumber#9 (7) {\n     private $countryCode =\u003e\n      int(41)\n     private $nationalNumber =\u003e\n      double(446681800)\n     private $extension =\u003e\n      NULL\n     private $italianLeadingZero =\u003e\n      NULL\n     private $rawInput =\u003e\n      NULL\n     private $countryCodeSource =\u003e\n      NULL\n     private $preferredDomesticCarrierCode =\u003e\n      NULL\n    }\n\nNow let us validate whether the number is valid:\n\n```php\n$isValid = $phoneUtil-\u003eisValidNumber($swissNumberProto);\nvar_dump($isValid); // true\n```\n\nThere are a few formats supported by the formatting method, as illustrated below:\n\n```php\n// Produces \"+41446681800\"\necho $phoneUtil-\u003eformat($swissNumberProto, \\libphonenumber\\PhoneNumberFormat::E164);\n\n// Produces \"044 668 18 00\"\necho $phoneUtil-\u003eformat($swissNumberProto, \\libphonenumber\\PhoneNumberFormat::NATIONAL);\n\n// Produces \"+41 44 668 18 00\"\necho $phoneUtil-\u003eformat($swissNumberProto, \\libphonenumber\\PhoneNumberFormat::INTERNATIONAL);\n```\n\nYou could also choose to format the number in the way it is dialled from another country:\n\n```php\n// Produces \"011 41 44 668 1800\", the number when it is dialled in the United States.\necho $phoneUtil-\u003eformatOutOfCountryCallingNumber($swissNumberProto, \"US\");\n\n// Produces \"00 41 44 668 18 00\", the number when it is dialled in Great Britain.\necho $phoneUtil-\u003eformatOutOfCountryCallingNumber($swissNumberProto, \"GB\");\n```\n\n## FAQ\n\n#### Problems with Invalid Numbers?\n\nThis library uses phone number metadata from Google's [libphonenumber](https://github.com/google/libphonenumber). If this library is working as intended, it should provide the same result as the Java version of Google's project.\n\nIf you believe that a phone number is returning an incorrect result, first test it with [libphonenumber](https://github.com/google/libphonenumber) via their [Online Demo](https://libphonenumber.appspot.com/). 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.\n\nIf Google's [Online Demo](https://libphonenumber.appspot.com/) gives a different result to the [libphonenumber-for-php demo](http://giggsey.com/libphonenumber/), then please raise an Issue on the [giggsey/libphonenumber-for-php](https://github.com/giggsey/libphonenumber-for-php) project.\n\nIf [giggsey/libphonenumber-for-php](https://github.com/giggsey/libphonenumber-for-php) differs from this library, please raise an issue here instead.\n\n## Generating data\n\nGenerating the data is not normally needed, as this repository will generally always have the up to date metadata.\n\nTo compile the data, run the composer script 'build'\n\n```bash\ncomposer run build\n```\n\nThis build process clones the [libphonenumber](https://github.com/google/libphonenumber) project at the version specified in [METADATA-VERSION.php](METADATA-VERSION.php).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiggsey%2Flibphonenumber-for-php-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiggsey%2Flibphonenumber-for-php-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiggsey%2Flibphonenumber-for-php-lite/lists"}