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

Filament Phone Input Laravel Package

erlenwald/filament-phone-input

Filament v5 phone input field with searchable country picker, favorites, per-country masks, and auto country detection. Configurable output format/state paths, optional country state field, default/IP lookup, and optional SVG flags. No intl-tel-input.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • Filament 5 Integration: Seamlessly integrates with Filament’s form builder, leveraging its field system (e.g., required(), label()). Aligns with Filament’s declarative, component-based architecture.
    • Normalization: Standardizes phone number formats (E164, national, etc.), reducing backend validation complexity.
    • Country-Specific Logic: Handles masks, validation, and flag display per country, reducing client-side JS complexity.
    • IP-Based Detection: Optional IP lookup for auto-country detection (useful for regional apps).
    • Extensibility: Supports custom state paths, formats, and translations via closures, enabling dynamic behavior (e.g., tenant-specific defaults).
  • Cons:

    • Filament 5 Dependency: Locks the package to Filament 5.x, limiting adoption in non-Filament Laravel apps.
    • No intl-tel-input: Relies on custom logic for phone validation/masking, which may require additional testing for edge cases (e.g., invalid numbers).
    • Asset Management: Requires manual publishing of flags/translations/CSS, adding operational overhead.

Integration Feasibility

  • Low Risk: PHP 8.2+ and Filament 5 compatibility ensures smooth integration with modern Laravel stacks.
  • Dependencies:
    • Core: Only requires Filament 5 (no heavy libraries like intl).
    • Optional: IP lookup needs a backend endpoint (e.g., /ip-country), adding minimal infrastructure requirements.
  • Frontend: Uses Alpine.js (bundled with Filament) and minimal custom CSS/JS, avoiding build tool conflicts.

Technical Risk

  • Validation: Server-side validation is not handled by the package—business logic must be implemented separately (e.g., via Laravel Validation rules or Form Requests).
  • Edge Cases:
    • Non-Standard Numbers: Some countries have complex numbering plans (e.g., mobile vs. landline prefixes). Custom masks may be needed.
    • IP Lookup Reliability: IP-based country detection can be inaccurate (e.g., VPNs, proxies) or slow. Should be optional/fallback-only.
  • Performance:
    • Flag Atlases: WebP/SVG assets are lightweight (~200KB), but SVG may increase initial load time.
    • Country Dropdown: Large lists (e.g., all 249 countries) could impact rendering. The countries() method mitigates this.

Key Questions

  1. Validation Strategy:
    • How will server-side validation (e.g., format, carrier, or business rules) be implemented? Will you use Laravel’s Validate or a custom library like libphonenumber?
  2. IP Lookup:
    • Is IP-based country detection critical, or should it be a fallback? What’s the backup for unreliable IP data?
  3. Customization Needs:
    • Will you need to override translations, CSS, or flags? Plan for publishing and caching steps.
  4. Scaling:
    • For multi-tenant apps, how will default countries/favorites be scoped (e.g., per tenant)?
  5. Testing:
    • Are there specific phone number formats (e.g., toll-free, VoIP) that require custom handling?
  6. Asset Management:
    • Will you automate flag/translation publishing (e.g., via CI) or handle it manually?

Integration Approach

Stack Fit

  • Ideal For:
    • Filament 5 Apps: Perfect for admin panels, user profiles, or CRM systems where phone inputs are common.
    • Regional Apps: Useful for apps targeting specific countries (e.g., restrict to ['US', 'CA']).
    • Global Apps with Localization: Supports multi-language flags/translations and country-specific masks.
  • Less Ideal For:
    • Non-Filament Projects: Requires Filament 5, limiting use in vanilla Laravel or other admin panel frameworks.
    • High-Volume Phone Validation: Relies on client-side formatting; server-side validation is mandatory.

Migration Path

  1. Prerequisites:
    • Upgrade to PHP 8.2+ and Filament 5.x.
    • Ensure filament/filament is installed (core dependency).
  2. Installation:
    composer require erlenwald/filament-phone-input
    
  3. Publish Assets:
    • Flags: Required for flag display.
      php artisan vendor:publish --tag=filament-phone-input-assets
      
    • Translations: If non-English/Russian support is needed.
      php artisan vendor:publish --tag=filament-phone-input-translations
      
    • CSS: For custom styling (optional).
      php artisan vendor:publish --tag=filament-phone-input-styles
      
  4. Clear Cache:
    php artisan optimize:clear
    php artisan filament:assets
    
  5. Implementation:
    • Replace existing phone input fields with PhoneInput::make('phone')->....
    • Example:
      PhoneInput::make('contact_number')
          ->label('Phone Number')
          ->required()
          ->defaultCountry('US')
          ->countries(['US', 'GB', 'DE'])
          ->phoneNumberFormat(PhoneNumberFormat::E164);
      

Compatibility

  • Backward Compatibility: None (Filament 5+ only).
  • Frontend Conflicts: Minimal risk—uses Alpine.js and Filament’s asset pipeline.
  • Database Schema: No changes required; state paths are configurable (e.g., store phone as E164 or national format).

Sequencing

  1. Phase 1: Install and publish assets in a staging environment.
  2. Phase 2: Replace one phone field in a non-critical form (e.g., test user profile).
  3. Phase 3: Gradually roll out to other forms, monitoring:
    • Flag display (CSS/asset loading).
    • IP lookup accuracy (if enabled).
    • Form submission validation.
  4. Phase 4: Customize translations/CSS for production needs.

Operational Impact

Maintenance

  • Updates:
    • Minor updates: Run composer update and republish assets if changes affect flags/translations.
    • Major updates: Test thoroughly—breaking changes may require state path or format adjustments.
  • Customizations:
    • Translations: Override published files (lang/vendor/...) for localization.
    • CSS: Extend resources/css/vendor/.../phone-input.css for styling.
    • Flags: Replace atlas files if custom flags are needed (e.g., corporate branding).
  • Dependencies:
    • Monitor Filament 5 updates for breaking changes.

Support

  • Troubleshooting:
    • Flags Not Loading: Verify asset publishing and filament:assets execution.
    • IP Lookup Failures: Check endpoint response format and CORS.
    • Validation Errors: Ensure server-side rules match the chosen phoneNumberFormat.
  • Community: Limited (0 stars/dependents); rely on GitHub issues or Filament forums.
  • Fallbacks:
    • Disable IP lookup if unreliable.
    • Use countries() to restrict to well-supported regions.

Scaling

  • Performance:
    • Country Dropdown: Limit with countries() to avoid rendering 249 options.
    • IP Lookup: Cache responses to avoid repeated API calls.
    • Assets: WebP flags are optimized; SVG may need lazy-loading for large apps.
  • Multi-Tenancy:
    • Use closures for dynamic defaults/favorites:
      ->defaultCountry(fn () => auth()->user()->preferredCountry)
      
  • High Traffic:
    • IP lookup endpoint may become a bottleneck; consider caching or disabling it.

Failure Modes

Failure Point Impact Mitigation
Missing flag assets Flags show as text codes Automate asset publishing in CI/CD.
IP lookup endpoint down No auto-country detection Disable IP lookup or use fallback.
Invalid phone format Server-side validation fails Implement robust Laravel validation.
CSS/JS conflicts Field renders incorrectly Test in isolation; inspect browser console.
Database schema mismatch Form submission errors Align state paths with existing DB.

Ramp-Up

  • Developer Onboarding:
    • 1 Hour: Install and test basic usage.
    • 2 Hours: Customize for a specific use case (e.g., restrict countries, add flags).
    • 4 Hours: Implement server-side validation and handle edge cases.
  • Documentation Gaps:
    • Missing: Examples for multi-tenant defaults, IP lookup endpoint specs, or validation rules.
    • Workaround: Use Filament’s existing field docs as a reference.
  • Training:
    • Focus on:
      • Asset publishing workflow.
      • State path configuration.
      • Server-side validation alignment.
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor