Welcome to libphonenumber for PHP
libphonenumber for PHP is a comprehensive library for parsing, formatting, storing and validating international phone numbers. This is a PHP port of Google’s libphonenumber library, providing the same powerful phone number handling capabilities to the PHP ecosystem.Quick Start
Get up and running in minutes with our quick start guide
API Reference
Explore the complete API documentation
Guides
Learn best practices and common patterns
Framework Integration
Integrate with Symfony, Laravel, and more
Key Features
Parse & Validate
Parse phone numbers from any format and validate them against international standards
Format Numbers
Format numbers for E.164, international, national, and RFC3966 formats
Geocoding
Get geographic location information for phone numbers
Carrier Mapping
Identify the carrier for mobile phone numbers
Timezone Mapping
Determine timezone information from phone numbers
Emergency Numbers
Handle short codes and emergency numbers correctly
As-You-Type
Format phone numbers in real-time as users type
Find Numbers
Extract phone numbers from text content
Why Use This Library?
Based on Google's libphonenumber
Based on Google's libphonenumber
This library is a direct port of Google’s authoritative libphonenumber library, ensuring accurate and up-to-date phone number handling for 250+ countries and territories worldwide.
Production-Ready
Production-Ready
With over 5,000 stars on GitHub and millions of downloads via Composer, this library is battle-tested and trusted by developers worldwide.
Actively Maintained
Actively Maintained
Regular updates keep the library in sync with Google’s libphonenumber releases, ensuring you always have the latest phone number metadata and validation rules.
Well-Documented
Well-Documented
Comprehensive documentation, code examples, and community support make it easy to integrate phone number validation into your application.
Requirements
- PHP: 8.1 to 8.5
- Extensions:
mbstring(PECL extension) - Dependencies: Automatically managed by Composer
This library follows Google’s versioning and may not strictly adhere to Semantic Versioning. Major version jumps may not contain backwards-incompatible changes. Always review release notes.
Quick Example
Here’s a simple example of parsing and validating a phone number:Next Steps
Install the library
Follow the installation guide to add libphonenumber to your project
Learn the basics
Work through the quickstart guide to understand core concepts
Explore features
Check out our guides for common use cases and patterns
Deep dive into the API
Browse the API reference for detailed documentation
Community and Support
- GitHub Repository: giggsey/libphonenumber-for-php
- Issues: Report bugs and request features on GitHub Issues
- Packagist: giggsey/libphonenumber-for-php
- Online Demo: Try the live demo to test phone number validation