A Laravel package for validating, formatting, and casting phone numbers using Google's libphonenumber.
Laravel Phone is a Laravel package that integrates Google's libphonenumber library to handle phone number validation, formatting, and casting. It solves the problem of processing international phone numbers correctly within Laravel applications by providing validation rules, Eloquent model casting, and utility methods for formatting and comparison.
Laravel developers building applications that require robust phone number handling, such as user registration forms, contact management systems, or international services needing phone validation and formatting.
Developers choose Laravel Phone because it seamlessly integrates with Laravel's validation and Eloquent ORM, leverages the reliable libphonenumber library for accurate international phone number processing, and offers features like casting and formatting that simplify phone number management in applications.
Phone number functionality for Laravel
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides validation rules, Eloquent casts, and helper functions that integrate directly into Laravel's ecosystem, as demonstrated in the validation and attribute casting sections.
Leverages Google's libphonenumber library via a reliable PHP port, ensuring accurate parsing, formatting, and validation for phone numbers worldwide.
Supports constraints on country, phone type (e.g., mobile), and leniency, with dynamic country field matching for form-based applications.
Includes a PhoneNumber class with methods like formatInternational() and formatForCountry(), simplifying display and dialing preparation.
E164PhoneNumberCast requires setting the country attribute before the phone number to avoid exceptions, adding fragility to model assignments as noted in the README.
The database considerations are labeled as thought starters with no support provided, forcing developers to build custom search and storage logic.
Relies on giggsey/libphonenumber-for-php-lite, which may introduce update delays or compatibility issues outside the package's control.