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

Laravel Phone Laravel Package

propaganistas/laravel-phone

Add robust phone number validation, casting, and formatting to Laravel using Google’s libphonenumber (PHP port). Validate by country or dynamic country fields, cast model attributes to phone objects, format numbers consistently, and compare/evaluate phone metadata.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature Development:

    • Phone Number Validation & Storage: Enable robust phone number validation (e.g., country-specific formats, mobile/fixed-line types) and standardized storage (E.164 format) for compliance with global standards.
    • User Experience: Improve UX by preserving raw user input (e.g., 012/34.56.78) while internally normalizing to E.164 for consistency.
    • Internationalization: Support multi-country phone numbers (e.g., validating US/UK/EU numbers in a single system) without custom logic.
    • Search & Uniqueness: Implement searchable phone number variants (normalized, national, E.164) for accurate lookups (e.g., customer support, fraud detection).
  • Roadmap Priorities:

    • Phase 1: Integrate validation and casting for core user models (e.g., users, contacts).
    • Phase 2: Add phone number formatting utilities for APIs/UI (e.g., display numbers locally or internationally).
    • Phase 3: Build search functionality for phone-based queries (e.g., "Find users with phone numbers starting with 012").
  • Build vs. Buy:

    • Buy: Avoid reinventing phone number parsing/validation (Google’s libphonenumber is battle-tested). Reduces technical debt and ensures compliance with global telecom standards.
    • Custom Build: Only consider if requirements are highly niche (e.g., supporting obscure number formats not covered by libphonenumber).
  • Use Cases:

    • Customer Onboarding: Validate phone numbers during signup (e.g., restrict to mobile numbers for SMS verification).
    • Global Support Systems: Format numbers for local dialing (e.g., display +44 20 1234 5678 for UK users, 00 44 20 1234 5678 for EU users).
    • Fraud Prevention: Flag invalid/non-standard numbers (e.g., VoIP numbers, blacklisted types).
    • Data Migration: Normalize legacy phone number formats (e.g., 1-800-123-4567+18001234567) during system upgrades.

When to Consider This Package

  • Adopt This Package If:

    • Your Laravel app requires phone number validation (e.g., signup forms, contact fields).
    • You need to store phone numbers in a standardized format (E.164) for global consistency.
    • Your users are international (e.g., multi-country support, regional formatting).
    • You want to avoid manual parsing of phone numbers (e.g., regex, custom logic).
    • Your team lacks expertise in telecom standards (e.g., ITU-T E.164, libphonenumber).
    • You need helper methods for formatting, comparison, or type detection (e.g., mobile vs. landline).
  • Look Elsewhere If:

    • You’re using a non-Laravel framework (this package is Laravel-specific).
    • Your phone number requirements are extremely niche (e.g., satellite phones, custom numbering plans).
    • You need real-time carrier lookup (e.g., toll-free numbers, spam detection) beyond basic validation.
    • Your app is highly regulated (e.g., telecom carriers) and requires custom compliance logic.
    • You’re already using a dedicated phone API (e.g., Twilio, Plivo) that handles validation internally.

How to Pitch It (Stakeholders)

For Executives:

*"This package leverages Google’s industry-standard libphonenumber to handle phone numbers in Laravel—saving us months of development time while ensuring compliance with global telecom standards. Key benefits include:

  • Reduced fraud: Validate and flag invalid/non-standard numbers (e.g., VoIP, blacklisted types).
  • Global scalability: Support international users with automatic formatting (e.g., display +44 20... for UK users, 00 44 20... for EU users).
  • Data consistency: Store numbers in E.164 format (e.g., +18001234567) to avoid duplicates and simplify searches.
  • Low risk: MIT-licensed, actively maintained, and used by 3,000+ projects. Integration is minimal (Composer install + validation rules), and we can phase it into high-impact areas like user onboarding and support systems."

For Engineering:

*"This package provides a drop-in solution for phone number handling in Laravel, built on libphonenumber-for-php-lite. Key features:

  • Validation: Country-specific rules (e.g., phone:US,BE), type constraints (mobile/landline), and lenient parsing.
  • Casting: Eloquent model attributes for RawPhoneNumberCast (preserves user input) or E164PhoneNumberCast (normalized storage).
  • Utilities: Format numbers for dialing (e.g., formatForCountry('US')), compare equality, or extract metadata (country, type).
  • Database: Supports E.164 storage or raw input + country codes; includes patterns for searchable variants. Example use case: Replace custom regex validation with phone:mobile in forms, and use E164PhoneNumberCast to standardize storage. The package handles edge cases (e.g., +32 (0) 12 34 56 78+3212345678)."*
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata