Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Libphonenumber For Php Lite Laravel Package

giggsey/libphonenumber-for-php-lite

Lite PHP port of Google’s libphonenumber for parsing, formatting, storing, and validating international phone numbers. Includes core PhoneNumberUtils only (no geolocation/carrier/short numbers). Requires PHP 8.1+ and mbstring; install via Composer.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Global User Onboarding & Validation: Enable frictionless international phone number collection (e.g., signup, 2FA, KYC) with parsing, validation, and formatting for 200+ countries.
  • Compliance & Data Integrity: Automate phone number validation to reduce fraud (e.g., invalid/malformed numbers) and ensure GDPR/regulatory compliance (e.g., emergency number detection).
  • Localization Features: Support region-specific formatting (e.g., +41 44 668 18 00 for Switzerland) and dialing instructions (e.g., 011 41... for US users).
  • Cost Optimization: Identify premium-rate/toll-free numbers (e.g., 1-800 in the US) to flag potential scams or adjust pricing logic.
  • Roadmap Priorities:
    • Build vs. Buy: Replace custom regex-based validation with a maintained, battle-tested library (Google-backed).
    • Scalability: Handle 100M+ user phone numbers without manual country-specific logic.
    • UX Improvements: Auto-format numbers in forms (e.g., +44 79...079... for UK users) and suggest corrections for typos.
  • Use Cases:
    • Auth Systems: Validate phone numbers during OTP/SMS verification.
    • Customer Support: Route calls to correct carriers (e.g., mobile vs. landline).
    • Marketplace/Finance: Detect toll-free numbers for vendor verification.
    • Emergency Services: Identify emergency numbers (e.g., 999 in the UK) for critical alerts.

When to Consider This Package

  • Adopt if:
    • Your app requires international phone number handling (parsing, validation, formatting) for 200+ countries.
    • You need carrier detection (e.g., Swisscom, AT&T) or short number validation (e.g., toll-free, premium rates).
    • You’re replacing custom regex/validation logic with a maintained, Google-backed solution.
    • Your team lacks telecom expertise to manually handle country-specific rules.
    • You need emergency number detection (e.g., 911, 112) for compliance or safety features.
  • Look elsewhere if:
    • You only need basic US/CA phone validation (consider twilio/php or libphonenumber-for-php-full for advanced features).
    • Your app is low-scale (e.g., <10K users) and can use simple regex.
    • You require real-time carrier lookup (this package uses static metadata; consider APIs like Twilio Lookup).
    • You’re on PHP <8.1 (unsupported) or lack the mbstring extension.
    • You need geolocation (use the full libphonenumber-for-php package instead).

How to Pitch It (Stakeholders)

For Executives: "This package lets us handle phone numbers globally—like Google does internally—without building or maintaining custom validation logic. It’s used by millions of apps (via Google’s libphonenumber) and will save dev time, reduce fraud (e.g., invalid numbers), and improve UX (e.g., auto-formatting for local users). For example, it can detect emergency numbers (e.g., 999 in the UK) or toll-free lines (e.g., 1-800 in the US) to flag risks or optimize costs. It’s a drop-in solution with zero ongoing maintenance."

For Engineering: *"This is a lite, high-performance PHP port of Google’s libphonenumber, focused on core phone number utils (parsing, validation, formatting). Key benefits:

  • Accuracy: Uses Google’s global phone number metadata (200+ countries).
  • Scalability: Handles edge cases (e.g., +44 7900 12345607900 123456 for UK).
  • Features:
    • Validate numbers (e.g., isValidNumber()).
    • Format for local/international use (e.g., NATIONAL, E164).
    • Detect number types (mobile, landline, VoIP).
    • Identify emergency/toll-free numbers.
  • Trade-offs: Lighter than the full package (no geolocation/carrier APIs), but covers 90% of use cases. Requires PHP 8.1+ and mbstring.
  • Integration: 5-minute setup via Composer. Example:
    $phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
    $number = $phoneUtil->parse('+44 7900 123456', 'GB');
    echo $phoneUtil->format($number, \libphonenumber\PhoneNumberFormat::NATIONAL); // '07900 123456'
    ```*
    
  • Alternatives: If we need carrier APIs or geolocation, we’d upgrade to the full package later. For now, this gives us 80% of the value with minimal overhead."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests