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.
Strengths:
giggsey/libphonenumber-for-php-lite), a battle-tested library for global phone number parsing, validation, and formatting.Weaknesses:
phone rules in Form Requests or manual validation (e.g., phone:US,BE).RawPhoneNumberCast or E164PhoneNumberCast) with automatic country resolution.phone()->formatInternational()) in controllers/views.giggsey/libphonenumber-for-php-lite (~1MB), which may impact cold starts in serverless environments.phone:INTERNATIONAL).phone_country) may require downtime or complex migrations.BE) may need dynamic updates if the app supports new regions.+1 (212))?PhoneNumber objects (e.g., in Redis) for repeated use?ZZ for unknown)?libphonenumber in unit tests for faster execution?propaganistas/laravel-phone.phone rules to Form Requests (e.g., phone:US,BE).RawPhoneNumberCast or E164PhoneNumberCast to models.phone_country column if needed).phone()->formatNational() etc.@php use Propaganistas\LaravelPhone\Facades\PhoneNumber;).composer.json for laravel/framework constraints.libphonenumber-for-php-lite v9+).illuminate/support v9+ breaking changes (e.g., enums).phone_country).| Step | Task | Dependencies | Risk | Effort |
|---|---|---|---|---|
| 1 | Install package | None | Low | 5 mins |
| 2 | Add validation to Form Requests | Step 1 | Low | 1 hour |
| 3 | Update model casts | Step 2 | Medium | 2 hours |
| 4 | Migrate existing data | Step 3 | High | 4+ hours |
| 5 | Replace custom formatting | Step 3 | Low | 1 hour |
| 6 | Optimize search/indexing | Step 4 | High | 3+ hours |
| 7 | Add caching (optional) | Step 5 | Low | 1 hour |
libphonenumber-for-php-lite may introduce breaking changes (e.g., enum shifts in v6.0.0).The phone field must be a valid number.).PhoneNumber::getErrorMessage() for detailed feedback.null instead of crashing).phone_e164 for uniqueness; consider full-text search for normalized variants.PhoneNumber objects in memory (e.g., static or Redis) for repeated use.How can I help you explore Laravel packages today?