Download the PHP package hejunjie/address-parser without Composer
On this page you can find all versions of the php package hejunjie/address-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hejunjie/address-parser
More information about hejunjie/address-parser
Files in hejunjie/address-parser
Package address-parser
Short Description 收货地址智能解析工具,支持从非结构化文本中提取姓名、手机号、身份证号、省市区、详细地址等字段,适用于电商、物流、CRM 等系统 | An intelligent address parser that extracts name, phone number, ID number, region, and detailed address from unstructured text—perfect for e-commerce, logistics, and CRM systems.
License MIT
Informations about the package address-parser
hejunjie/address-parser
An intelligent address parser that extracts name, phone number, ID number, province, city, district, and detailed address from unstructured text — ideal for e-commerce, logistics, and CRM systems.
For a quick project overview, check out the Zread analysis. If you'd rather not deploy it yourself, try the online tool, which also supports batch queries.
Features
- User Info Extraction: Automatically recognizes name, phone number, ID number, and postal code
- Smart Address Matching: Intelligently resolves administrative divisions using nationwide province/city/district data
- Structured Output: Returns a consistent array format for easy frontend-backend integration
- Flexible Configuration: Supports custom division data sources and configurable fallback values
- PHP 7.4+ / 8.0+ with ext-mbstring required
Installation
Quick Start
Output:
API
AddressParser::parse()
Built-in division data is sourced from hejunjie/china-division and updated regularly.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
$string |
string |
required | The raw address string to parse |
$user |
bool |
true |
Set to false to skip user info extraction and only parse the address |
$unknownValue |
string |
'未知' |
Fallback value for unmatched province/city/district |
$level1Data |
array |
[] |
Custom province data (see china-division format) |
$level2Data |
array |
[] |
Custom city data |
$level3Data |
array |
[] |
Custom district/county data |
Batch Parsing Example:
Return Fields
| Field | Type | Description |
|---|---|---|
name |
string |
Full name |
mobile |
string |
Phone number |
idn |
string |
National ID number |
postcode |
string |
Postal code |
province |
string |
Province name |
city |
string |
City name |
region |
string |
District/county name |
street |
string |
Street address (remaining text after removing province, city, and district) |
Use Cases
In real-world scenarios, user-submitted addresses are often unstructured. For example:
张三 13512345678 北京市朝阳区建国路88号 邮编100000
Manually parsing such strings is inefficient and error-prone. hejunjie/address-parser is designed specifically for these situations:
- Order address processing in e-commerce systems
- Address recognition in logistics and delivery services
- User profile completion in admin panels
- Address input validation in mini-programs and mobile apps
If you have any questions or suggestions, feel free to open an issue. I'll respond as soon as I can.
Acknowledgements
The inspiration for this package came from a friend who mentioned the idea in an issue on one of my other repositories and kindly shared the pupuk/address implementation. That spark led to hejunjie/address-parser — many thanks for the inspiration 🙌