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

Phone Number Bundle Laravel Package

misd/phone-number-bundle

Symfony bundle integrating Google’s libphonenumber via giggsey/libphonenumber-for-php. Provides services and helpers to parse, validate, format, and geocode phone numbers in Symfony 2–4 apps. Abandoned; use odolbeau/phone-number-bundle instead.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature Development:

    • Global Phone Number Validation: Enable validation of phone numbers across regions (e.g., for user signups, customer profiles, or contact forms) with support for regional formats (e.g., +1 (123) 456-7890 vs. 020 1234 5678).
    • Geocoding and Carrier Lookup: Integrate phone number geocoding (e.g., mapping numbers to cities/countries) or carrier identification (e.g., for telecom analytics or fraud detection) via PhoneNumberOfflineGeocoder or PhoneNumberToCarrierMapper.
    • User Experience (UX) Enhancements:
      • Smart Form Inputs: Implement country-specific phone number fields (e.g., dropdown for country + localized number format) using the PhoneNumberType form widget.
      • Dynamic Formatting: Auto-format phone numbers in templates (e.g., Twig) for consistency (e.g., +44 20 1234 5678 vs. 442012345678).
    • Data Migration/Storage:
      • Standardize phone number storage in databases using phone_number Doctrine type (stores as E.164 format, e.g., +14155552671).
      • Migrate legacy phone number data to standardized formats during database schema updates.
    • Compliance and Fraud Prevention:
      • Validate phone number types (e.g., mobile vs. landline) for KYC (Know Your Customer) or age verification (e.g., reject toll-free numbers for under-18 users).
      • Detect VoIP or premium-rate numbers to flag potential fraud (e.g., scam calls).
  • Roadmap Prioritization:

    • Phase 1 (MVP): Focus on core validation and storage (e.g., Symfony forms + Doctrine types).
    • Phase 2 (Scaling): Add geocoding/carrier lookup for advanced use cases (e.g., analytics, localization).
    • Phase 3 (Polish): Enhance UX with country-specific inputs and dynamic formatting.
  • Build vs. Buy:

    • Buy: Avoid reinventing phone number parsing/validation logic (libphonenumber is battle-tested for global coverage).
    • Build: Only if needing Laravel-specific features (e.g., Blade templating, Laravel Scout integration) or custom logic not covered by the bundle.
    • Hybrid: Use this bundle as a reference implementation to build a Laravel-adapted version (e.g., abstract Symfony dependencies).
  • Use Cases:

    • Customer Portals: Validate and format phone numbers for user profiles.
    • SMS/Email Services: Ensure phone numbers are correctly parsed for messaging APIs (e.g., Twilio).
    • Marketplace Platforms: Verify seller/customer phone numbers for compliance (e.g., age restrictions).
    • Logistics/Field Teams: Geocode phone numbers to assign regional support teams or validate local numbers.

When to Consider This Package

  • Adopt This Package If:

    • You’re using Symfony 2–4 and need a turnkey solution for phone number handling (validation, storage, formatting).
    • Your app requires global phone number support (e.g., multi-country users, internationalization).
    • You prioritize maintainability over custom code (libphonenumber is actively maintained by Google).
    • You need Doctrine integration (e.g., storing phone numbers in databases with proper formatting).
    • Your team lacks expertise in phone number parsing logic (libphonenumber handles edge cases like invalid formats, regional variations).
  • Look Elsewhere If:

    • You’re using Laravel (this bundle is Symfony-specific; see alternatives like giggsey/libphonenumber-for-php directly or Laravel wrappers).
    • You need real-time geocoding (this bundle includes an offline geocoder; consider a third-party API like Google Maps or Twilio Lookup).
    • You require active maintenance (last release was 2018; though libphonenumber itself is actively updated).
    • You need Blade templating support (Twig-only; would require custom integration).
    • You’re building a microservice and want to avoid Symfony dependencies (e.g., for a Laravel API).
  • Alternatives to Evaluate:

    • For Laravel: Use giggsey/libphonenumber-for-php directly or a Laravel wrapper like overtrue/phone.
    • For Real-Time Geocoding: Integrate a service like Twilio Lookup or Google’s Phone Number API.
    • For Lightweight Needs: Use a simpler package like egulias/email-validator (if phone validation is minimal).

How to Pitch It (Stakeholders)

For Executives:

*"This package lets us handle phone numbers globally with zero custom development—saving 3–6 months of work. It’s used by enterprises like [hypothetical companies] to validate, store, and format phone numbers across 200+ countries, reducing fraud and improving user experience. For example, we can:

  • Automate compliance: Reject invalid or premium-rate numbers for signups.
  • Localize forms: Show country-specific phone inputs (e.g., ‘+44’ for UK users).
  • Cut support costs: Geocode numbers to route calls to the right regional team. The upfront cost is minimal (a Composer install), and the ROI comes from faster development, fewer bugs, and scalability for international markets."*

Risk Mitigation: *"The package is abandoned, but it wraps Google’s libphonenumber—a library used by Google, Twilio, and Stripe. We’d mitigate risks by:

  1. Forking it for Laravel if needed (low effort, since it’s ~90% libphonenumber).
  2. Adding a fallback to a maintained alternative (e.g., overtrue/phone) if issues arise."*

For Engineering Teams:

*"This bundle integrates libphonenumber (Google’s gold standard for phone parsing) into Symfony via a well-structured API. Here’s how we’d leverage it:

Key Features:

  • Validation: Use @AssertPhoneNumber to validate phone numbers in forms (e.g., reject VoIP numbers for KYC).
  • Storage: Store phone numbers in Doctrine as E.164 format (e.g., +14155552671) via a custom DBAL type.
  • Forms: Two widget options:
    • Single field (e.g., +1 (123) 456-7890).
    • Country dropdown + localized number input (e.g., GB + 020 1234 5678).
  • Templates: Format numbers dynamically in Twig (e.g., {{ phone|phone_number_format('NATIONAL') }}).
  • Advanced: Geocode numbers (offline) or map to carriers/time zones.

Implementation Plan:

  1. Phase 1: Add to composer.json and configure Doctrine/Twig services.
  2. Phase 2: Replace legacy phone number fields with PhoneNumberType forms.
  3. Phase 3: Add validation constraints (e.g., @AssertPhoneNumber(type="mobile")).

Trade-offs:

  • Symfony-only: If we need Laravel, we’ll abstract the Symfony-specific parts (e.g., AppKernel) or switch to overtrue/phone.
  • Maintenance: Last release was 2018, but libphonenumber is actively updated. We’ll monitor for forks or create a lightweight Laravel wrapper if needed.

Example Use Case: For a user signup form, we’d replace:

// Legacy
$builder->add('phone', TextType::class);

With:

// New
$builder->add('phone', PhoneNumberType::class, [
    'default_region' => 'US',
    'widget' => PhoneNumberType::WIDGET_COUNTRY_CHOICE,
    'country_choices' => ['US', 'GB', 'CA'],
]);

This auto-validates, formats, and stores numbers correctly—no more manual parsing!"*

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.
datacore/hub-sdk
alengo/sulu-http-cache-bundle
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard
visualbuilder/filament-lottie
servicioslineaonce/starter-kit
atomcoder/laravel-reorderable
irajul/filament-shadcn-theme
agtp/agtp-php
agtp/mod-php
centraldesktop/protobuf-php
trappistes/laravel-custom-fields
splash/sonata-admin
splash/metadata