Requirements
Before installing libphonenumber for PHP, ensure your environment meets these requirements:- PHP 8.1 to 8.5 - The library supports all current PHP 8.x versions
- mbstring extension - Required for proper string handling
The library will be updated to use supported versions of PHP without major version bumps.
Install with Composer
The recommended way to install libphonenumber for PHP is via Composer:- Download the library and its dependencies
- Set up PSR-4 autoloading automatically
- Make all classes available under the
libphonenumber\namespace
Alternative: Lite Version
If you only need core phone number parsing, validation, and formatting functionality, consider using the lite version for a smaller package size:The lite version excludes additional features like geocoding, carrier mapping, and timezone mapping. Use the standard version if you need these capabilities.
Manual Installation
If you’re not using Composer, you can manually install the library:- Download the source code from GitHub
- Set up a PSR-4 compliant autoloader
- Manually install dependencies:
Verify Installation
After installation, verify everything is working by creating a simple test script:Next Steps
Quick Start
Learn how to parse, validate, and format phone numbers
PhoneNumberUtil Reference
Explore all available methods and features