viison/address-splitter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

viison/address-splitter

Composer 安装命令:

composer require viison/address-splitter

包简介

Tries to split an address line into street name, house number and other additional information like building, apartment information etc.

README 文档

README

Packagist Build Status Software License

Tries to split an address line into street name, house number and other additional information like building, apartment information etc.

Installation

This project can be installed via Composer:

$ composer require viison/address-splitter

Usage

The AddressSplittingService only contains one static function splitAddress that performs the address splitting. The function expects one parameter, which is the address line. The function returns an associative array with the keys additionToAddress1, streetName, houseNumber and additionToAddress2. additionToAddress1 and additionToAddress2 contain information given in front of or after the street name & house number, respectively.

Example

You can use the address splitting service as follows:

var_dump(\VIISON\AddressSplitter\AddressSplitter::splitAddress('Pallaswiesenstr. 57B App. 235'));

The output of this command will be:

array(4) {
	["additionToAddress1"]=>
	string(0) ""
	["streetName"]=>
	string(16) "Pallaswiesenstr."
	["houseNumber"]=>
	string(2) "57B"
	["houseNumberParts"]=> array(2) {
	    ["base"]=>
	    string(2) "57"
	    ["extension"]=>
	    string(1) "B"    
	}
	["additionToAddress2"]=>
	string(8) "App. 235"
}

Supported Address Formats

We try to support all address formats used world-wide. E.g., the address splitter will work no matter if the house number is given in front of or after the street name.

Here is a number of examples of addresses and how their splitted representation looks like:

Address line additionToAddress1 streetName houseNumber base extension additionToAddress2
56, route de Genève route de Genève 56 56
Piazza dell'Indipendenza 14 Piazza dell'Indipendenza 14 14
Neuhof 13/15 Neuhof 13/15 13 15
574 E 10th Street E 10th Street 574 574
1101 Madison St # 600 Madison St 1101 1101 # 600
3940 Radio Road, Unit 110 Radio Road 3940 3940 Unit 110
D 6, 2 D 6 2 2
13 2ème Avenue 2ème Avenue 13 13
Apenrader Str. 16 / Whg. 3 Apenrader Str. 16 16 Whg. 3
Pallaswiesenstr. 57 App. 235 Pallaswiesenstr. 57 57 App. 235
Kirchengasse 7, 1. Stock Zi.Nr. 4 Kirchengasse 7 7 1. Stock Zi.Nr. 4
Wiesentcenter, Bayreuther Str. 108, 2. Stock Wiesentcenter Bayreuther Str. 108 108 2. Stock
244W 300N #101 W 300N 244 244 #101
Corso XXII Marzo 69 Corso XXII Marzo 69 69
Frauenplatz 14 A Frauenplatz 14 A 14 A
Mannerheimintie 13A2 Mannerheimintie 13A2 13 A2
Kerkstraat 13-HS Kerkstraat 13-HS 13 HS
Poststr. 15-WG2 Poststr. 15-WG2 15 WG2
Hollandweg1A Hollandweg 1A 1 A
Poststr. 2 1/2 Poststr. 2 1/2 2 1/2
Breitenstr. 13/15/8/6 Breitenstr. 13/15/8/6 13 13/15/8/6
Österreicher Weg 12A/8/6 Österreicher Weg 12A/8/6 12 A/8/6
Schegargasse 13-15/8/6 Schegargasse 13-15/8/6 13 15/8/6

Unit Tests

The examples above and even more exemplary address lines are part of our unit tests. The unit tests can be run on the following site: https://regex101.com/r/vO5fY7/5

You can also run the tests via PHPUnit from the command line:

$ phpunit

If you don't have PHPUnit installed globally, run composer install first.

Further Information

The need for this functionality came up when we noticed that Shopware 5 does not contain individual fields for the street name and the house number anymore. Nevertheless, we needed to have these separated for our DHL Adapter, because the DHL API expects them to be passed individually.

More background information on how this implementation came together can be found in our blog post.

Adresstrennung

Dieses Projekt ermöglicht es, eine Adresszeile in Straßennamen und Hausnummer sowie weitere Angaben wie z.B. Gebäude- oder Appartmentinformationen zu trennen. Unterstützt werden eine Vielzahl an Adressformaten, wie sie weltweit verwendet werden. So ist es z.B. unerheblich, ob die Hausnummer auf die Straße folgt oder ihr voran steht.

License

viison/address-splitter is licensed under the MIT license. See the LICENSE file for more details.

viison/address-splitter 适用场景与选型建议

viison/address-splitter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.92M 次下载、GitHub Stars 达 103, 最近一次更新时间为 2015 年 04 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 viison/address-splitter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 viison/address-splitter 我们能提供哪些服务?
定制开发 / 二次开发

基于 viison/address-splitter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.92M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 104
  • 点击次数: 18
  • 依赖项目数: 12
  • 推荐数: 0

GitHub 信息

  • Stars: 103
  • Watchers: 10
  • Forks: 22
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-23