giggsey/libphonenumber-for-php
64.5
Adequate · 19 September 2026
492.7k
lines of production code
PHP
primary language
1
measurement over time
What this system is
This system is a PHP library for parsing, formatting, and validating international phone numbers, serving as a modernized port of Google's libphonenumber. It provides core utilities for number validation with configurable leniency, real-time as-you-type formatting, and extraction of numbers from unstructured text. Additionally, it offers offline capabilities to map phone prefixes to carrier information, geographic locations, and time zones.
Features
Added offline phone number geocoding capability
Introduced the PhoneNumberOfflineGeocoder class, enabling users to retrieve human-readable text descriptions (such as country or area names) for valid phone numbers based on a specified locale. This feature allows for detailed geographical context, such as omitting the user's own country from the description for local numbers, by leveraging prefix mapping data and CLDR region codes.
src/geocoding · high confidence
Introduce As-You-Type formatting and text-based phone number matching
The library now supports real-time phone number formatting as digits are entered via the new AsYouTypeFormatter class, and allows extracting phone numbers embedded within larger text blocks using the PhoneNumberMatcher. These additions provide immediate visual feedback during data entry and enable parsing numbers from unstructured content like emails or documents.
src · high confidence
Introduce leniency levels for phone number validation
The library now supports configurable leniency levels when validating phone numbers, allowing users to choose how strictly input formatting is enforced. Five levels are available: Possible (accepts any structurally possible number), Valid (requires a valid number with correct national prefix usage), StrictGrouping (requires valid grouping consistent with the locale), and ExactGrouping (requires exact formatting match). This change enables more flexible or stricter validation depending on the user's needs, improving usability for inputs that may not be perfectly formatted.
src/Leniency · high confidence
Behavioural changes
Build system migrated from Phing to PHP scripts with updated tooling configuration
The project has replaced the Phing-based build process with a PHP script for building metadata, removing the legacy build.xml file. This change is accompanied by the addition of configuration files for modern development tooling, including .editorconfig for consistent code formatting, .gitattributes and .gitignore to manage repository exports, and configuration files for PHP CS Fixer, PHPUnit, PHPStan, and Infection mutation testing. The build configuration now enforces stricter standards, such as requiring PHP 8.1+ and using PSR-4 autoloading, while excluding test and build artifacts from production releases.
(repo-wide) · high confidence
Carrier data updated to libphonenumber-for-php v9
The carrier lookup data in src/carrier has been regenerated from the upstream libphonenumber-for-php v9 dataset. This update refreshes the internal carrier mapping files (such as Map.php and the language-specific carrier classes) to align with the latest Google libphonenumber metadata, ensuring that carrier identification for phone numbers reflects current network assignments.
src/carrier · high confidence
New PHP-based build system for phone number metadata
The project has replaced its previous build tooling (Phing) with a new PHP-based command-line application located in the \build/\ directory. This new system uses Symfony Console and Nette PhpGenerator to parse XML metadata and generate optimized PHP data files for phone prefixes, time zones, and region codes. This change is part of the broader v9 release, which also includes PHP 8.1 and 8.4 compatibility updates and the addition of short number support.
build · high confidence
Refactored prefix mapper to use dedicated data classes
The phone prefix mapping logic in src/prefixmapper has been restructured to store metadata and data in dedicated classes rather than raw arrays. New classes include MappingFileProvider for managing available data files, PhonePrefixMap for mapping prefixes to descriptions, PrefixFileReader for handling file loading and language fallback, and PrefixTimeZonesMap for retrieving timezone information. This change improves type safety and maintainability of the prefix mapping system.
src/prefixmapper · high confidence
Replace Phing build system with Symfony Console commands
The build process for libphonenumber metadata has been migrated from the Phing tool to a set of PHP scripts using the Symfony Console component. This change introduces new command-line tools (BuildCommand, BuildMetadataPHPFromXMLCommand, GeneratePhonePrefixDataCommand, and GenerateTimeZonesMapDataCommand) that handle the generation of phone number, carrier, timezone, and geocoding data files. Users building the library from source will now use these Symfony-based commands instead of the previous Phing targets.
build/Commands · high confidence
Updated alternate phone number formatting metadata for multiple countries
The \src/data\ directory has been updated with new \PhoneNumberAlternateFormats\\.php\ files for numerous countries (including Ethiopia, South Africa, Greece, the Netherlands, Spain, Gibraltar, Portugal, Luxembourg, Finland, Bulgaria, Hungary, Estonia, Moldova, Ukraine, Serbia, Croatia, Italy, Austria, the UK, Germany, Nicaragua, Costa Rica, Mexico, Argentina, Brazil, Venezuela, Paraguay, Australia, and Indonesia). These generated data files define specific national number formatting patterns and leading-digit rules, ensuring that phone numbers for these regions are formatted correctly according to the latest upstream Google libphonenumber metadata.
src/data · high confidence
Updated geocoding data for libphonenumber-for-php v9.0.30
The geocoding data files in src/geocoding/data have been regenerated to align with the upstream libphonenumber metadata for version 9.0.30. This update refreshes the internal PHP classes (such as Map, Ar\_966, Be\_375, and En\_12) that map phone number prefixes to geographic locations, ensuring that location lookups reflect the latest changes from Google's libphonenumber dataset.
src/geocoding/data · high confidence
Test coverage
Added core test suite for phone number parsing, formatting, and validation; Added regression tests for specific phone number handling issues; Added test bootstrap configuration; Added test data for carrier and prefixmapper lookups; Added test data map for timezone validation; Added tests for PhoneNumberToCarrierMapper; Added tests for phone number to timezone mapping; Added unit tests for build tool metadata and prefix generation; Added unit tests for geocoding and prefix mapping; Updated test metadata for libphonenumber.
Dependencies
Initial release of libphonenumber-for-php v9 with PHP 8.1+ and modern tooling
This entry introduces the v9 major version of the library, establishing a new baseline that requires PHP 8.1 or higher and adopts PSR-4 autoloading. The dependency stack has been modernized to use giggsey/locale ^2.7 and symfony/polyfill-mbstring ^1.31, while development tooling has been updated to PHPUnit ^10.5.45, PHPStan ^2.1.7, and PHP-CS-Fixer ^3.71. The package is configured to replace giggsey/libphonenumber-for-php-lite and includes build scripts for metadata generation and static analysis.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 64.
Lenses
- Code Health 100
- Architecture 66
- Maturity 55
- Readiness 67
- Security 91
Changes since last survey
- 300 commits — 275 feature/other, 25 fixes
By area
- (repo) — 122 commits
- src/data — 72 commits
- (root) — 23 commits
- src/carrier — 20 commits
- src/PhoneNumberUtil.php — 18 commits
- .github/workflows — 12 commits
- src/PhoneNumber.php — 6 commits
- build/BuildMetadataFromXml.php — 4 commits
- src/AsYouTypeFormatter.php — 3 commits
- tests/Issues — 3 commits
- tests/core — 3 commits
- build/BuildMetadataPHPFromXml.php — 2 commits
- src/PhoneNumberToTimeZonesMapper.php — 2 commits
- src/geocoding — 2 commits
- src/prefixmapper — 2 commits
- src/DefaultMetadataLoader.php — 1 commit
- src/Matcher.php — 1 commit
- src/NumberFormat.php — 1 commit
- src/NumberParseException.php — 1 commit
- src/PhoneNumberDesc.php — 1 commit
Notable commits
- fix: :art: Fix code styling
- fix: :art: Fix code styling
- fix: :art: Fix code styling
- fix: :art: Fix code styling
- fix: :art: Fix code styling
- fix: :green_heart: Fix PHPStan
- fix: :green_heart: Fix PHPStan
- fix: Fix Infection exclusions
- fix: Fix PHP 8.4 compatibility
- fix: Fix PHP CS Fixer running via GitHub Actions for forks
- fix: Fix PHPStan
- fix: Fix PHPStan warnings
- fix: Fix PhoneNumber comparison
- fix: Fix composer.json
- fix: Fix deprecation: Using null as an array offset is deprecated, use an empty string instead
- fix: Fix generating classmaps for data
- fix: Fix internal tests
- fix: Fix pipelines
- fix: Fix string parameter type hinted as integer
- fix: Fix truncateTooLongNumber on 32 bit PHP
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
giggsey/libphonenumber-for-php was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 268d42f8f6401d94fd3c5c9dddb09290f81ed613 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.