giggsey/libphonenumber-for-php-lite
A lightweight PHP library for parsing, formatting, storing, and validating international phone numbers, based on Google's libphonenumber. This lite version includes core phone number utilities and requires PHP 8.1+ with mbstring.
Architecture fit
PhoneNumberUtil::getInstance()) with static-ish semantics; the natural Laravel shape is a thin PhoneNumber value object plus a PhoneNumberService bound in the container, so application code never touches libphonenumber\* directly.Integration feasibility
isNumberMatch (confidence levels) and getNumberType (fixed-line/mobile/toll-free/VoIP) are the highest-leverage features beyond basic validation — they enable SMS-only routing rules and fraud heuristics at near-zero cost.Technical risk
PhoneNumber objects is the exposure point. Constrain to ^9.0 and treat any major bump as a change requiring review, not an automatic merge.giggsey/libphonenumber-for-php is required — same namespace, larger data footprint.Key questions
PhoneNumber objects (cache, queue payloads, DB columns)? If so, the 9.x serialization change is a migration, not a routine bump.Stack fit
App\Support\PhoneNumber value object (raw input, E.164, national, region, type) → PhoneNumberService wrapping PhoneNumberUtil → a ValidPhoneNumber validation rule and a custom Eloquent cast. Everything above the service is then library-agnostic.getInstance() is called once and the metadata cache is shared per process.Migration path
str_replace punctuation stripping, and manual + prefixing. Each site is a candidate for replacement and a potential source of duplicate or inconsistent stored formats.PhoneNumber serializations in the same release as the backfill; separate the concerns.Compatibility
Sequencing
composer.lock, dependency bot configured to open PRs but require the fixture suite plus a manual reviewer.NumberParseException and invalid-number rate by region, so a metadata regression shows up as a metric rather than as a support ticket.Maintenance
composer run build) clones Google's repo; it is not something we run in CI. Consume published releases only.Support
Scaling
Failure modes
isValidNumber; store raw input, normalize best-effort, and flag for review rather than reject.NumberParseException. It is thrown, not returned. An unguarded call inside a chunked job aborts the batch; wrap at the service boundary and convert to a domain result object.PhoneNumber objects can fail to unserialize across a major version. Store scalars (E.164 strings) in durable storage; treat the object as in-memory only.Ramp-up
PhoneNumber value object, not on libphonenumber\PhoneNumberUtil — that keeps the lite-to-full upgrade, or a future swap, a one-file change.How can I help you explore Laravel packages today?