ad3n/phone-number-bundle
Symfony bundle integrating Google libphonenumber (via giggsey/libphonenumber-for-php). Provides services for parsing, validating, formatting, geocoding, carrier and timezone mapping, plus short number info, for Symfony 2–4 apps.
MisdPhoneNumberBundle class relies on Symfony’s Bundle base class, which is incompatible with Laravel’s ServiceProvider/Package model.giggsey/libphonenumber-for-php, a PHP port of Google’s libphonenumber. This library is language-agnostic and could theoretically be used in Laravel, but the bundle itself is not.giggsey/libphonenumber-for-php integration (no bundle needed).egulias/phoneparser (more mature, actively maintained).Bundle with a Laravel ServiceProvider/Package.config/services.php).libphonenumber-for-php usage patterns.giggsey/libphonenumber-for-php been tested directly in Laravel? If so, what were the results?egulias/phoneparser) that offer equivalent or superior functionality?libphonenumber-for-php?libphonenumber-for-php Integration:
composer require giggsey/libphonenumber-for-php
Usage:
use libphonenumber\PhoneNumberUtil;
use libphonenumber\PhoneNumberFormat;
$util = PhoneNumberUtil::getInstance();
$number = $util->parse('+14155552671', 'US');
echo $util->format($number, PhoneNumberFormat::E164);
egulias/phoneparser (more feature-rich, actively maintained).illuminate/validation with custom rules for basic validation.libphonenumber-for-php and Laravel alternatives.libphonenumber-for-php directly in Laravel to validate functionality.PhoneNumberUtil for consistency.libphonenumber-for-php lacks Laravel-specific conveniences (e.g., Eloquent casting), consider:
// Example: Eloquent phone number casting
use Egulias\Phone\Parser\PhoneNumber;
use Egulias\Phone\Validator\PhoneNumberValidator;
class User extends Model {
protected $casts = [
'phone_number' => PhoneNumberCast::class,
];
}
libphonenumber-for-php is compatible with Laravel (no framework dependencies).Form types).libphonenumber-for-php directly in Laravel.libphonenumber-for-php or a Laravel package.libphonenumber-for-php) may evolve, requiring manual updates.libphonenumber-for-php is actively maintained (though PHP port may lag behind Java).egulias/phoneparser have better community support.libphonenumber-for-php or Symfony community resources.egulias/phoneparser has active issue tracking and Laravel-specific documentation.libphonenumber-for-php is CPU-intensive for large-scale parsing (Google’s Java version is optimized; PHP port may not be).libphonenumber-for-php usage is lighter.| Failure Scenario | Bundle Risk | Laravel Alternative Risk |
|---|---|---|
| Bundle breaks due to Symfony DI | High (incompatible) | None (avoided) |
libphonenumber-for-php updates |
Medium (bundle may not adapt) | Medium (direct integration requires testing) |
| Missing Laravel-specific features | High (no form/validation helpers) | Low (custom solutions or packages exist) |
| Poor performance at scale | Medium (bundle adds overhead) | Medium (library itself is the bottleneck) |
| No community support | Critical | Lower (Laravel packages have more support) |
DependencyInjection).libphonenumber-for-php (direct usageHow can I help you explore Laravel packages today?