Overview
The giggsey/libphonenumber-for-php-lite package is a streamlined version that includes: ✅ Core PhoneNumberUtil functionality ✅ Phone number parsing ✅ Phone number formatting ✅ Phone number validation ✅ All country metadata ❌ Geocoding (PhoneNumberOfflineGeocoder) ❌ Carrier mapping (PhoneNumberToCarrierMapper) ❌ Timezone mapping (PhoneNumberToTimeZonesMapper) ❌ Short number information (ShortNumberInfo)The lite version includes all the same metadata as the full version, so it supports all countries and regions. The only difference is the exclusion of additional features beyond core phone number operations.
Installation
Install the lite version using Composer:Package Size Comparison
The lite version offers significant space savings:| Package | Installed Size | Download Size |
|---|---|---|
| Full Version | ~15-20 MB | ~3-4 MB |
| Lite Version | ~10-12 MB | ~2-3 MB |
- Geocoding data files
- Carrier mapping data files
- Timezone mapping data files
- Short number metadata
- Related class files
When to Use Lite Version
Choose the lite version when:Basic Operations Only
You only need parsing, formatting, and validation
Package Size Matters
Minimizing deployment size is important (containers, serverless)
Memory Constraints
Running in memory-limited environments
Faster Deployments
Quicker deployment times are a priority
When to Use Full Version
Choose the full version when you need:- Geocoding: Determining geographic location from phone numbers
- Carrier Information: Identifying mobile network operators
- Timezone Mapping: Finding timezones for phone numbers
- Short Numbers: Validating emergency numbers, toll-free numbers, etc.
Usage Comparison
The API is identical for features included in both versions:Lite Version ✅
Full Version Only ❌
Migration Guide
Switching FROM Full TO Lite
- Audit your codebase for usage of excluded features:
- Refactor or remove features that depend on excluded functionality
- Update composer.json:
- Run composer update:
Switching FROM Lite TO Full
Switching from lite to full is seamless since the lite version is a subset:Composer Replace
The full package includes areplace directive in composer.json:
Understanding Composer Replace
Understanding Composer Replace
The
replace directive tells Composer that the full package can be used anywhere the lite package is required. This is useful when:- A dependency requires the lite version
- You want to use the full version
- Both can coexist in the same dependency tree
Performance Considerations
Memory Usage
Both versions have similar memory usage for core operations since they use the same metadata structure. The difference is in features not loaded:Loading Time
The lite version loads slightly faster due to:- Fewer class files to autoload
- No additional data files to discover
- Smaller overall codebase
After the first request with OPcache enabled, performance differences between versions are negligible for core operations.
Use Cases
Serverless Functions
The lite version is ideal for AWS Lambda, Google Cloud Functions, etc.:- Faster cold starts
- Lower memory usage
- Smaller deployment package
Docker Containers
Reduce Docker image size:API Services
For phone number validation APIs:Decision Matrix
I only validate and format phone numbers
I only validate and format phone numbers
Use the lite version. You don’t need the additional features, and you’ll benefit from the smaller package size.
I need to show geographic location of phone numbers
I need to show geographic location of phone numbers
Use the full version. The geocoding feature is not available in the lite version.
I validate emergency numbers
I validate emergency numbers
Use the full version. ShortNumberInfo is required for emergency number validation.
I'm deploying to a serverless platform
I'm deploying to a serverless platform
Consider the lite version if you only need core functionality. The smaller package size results in faster deployments and lower costs.
I might need additional features in the future
I might need additional features in the future
Use the full version. It’s easier to start with the full version than to migrate later if you discover you need additional features.
Related Topics
- Performance - Optimization strategies for both versions
- PhoneNumberUtil - Core functionality available in both versions