torann/address-format
Composer 安装命令:
composer require torann/address-format
包简介
A PHP library to parse street addresses to localized formats
README 文档
README
A PHP library to parse street addresses to localized formats. The address formats are based on the formats supplied by Google's libaddressinput.
Installation
Composer
From the command line run:
$ composer require torann/address-format
Usage
Formatting
format(array $data, $html = false)
Arguments:
$data- An array of address elements$html- When set to true the address elements will be wrapped withspantags.
NOTE: The wrapping span tags contain itemprop attributes that adhere to the PostalAddress schema.
Usage:
$address = \Torann\AddressFormat\Address::format([ 'recipient' => 'Jane Doe', 'organization' => 'Whitworth Institute Inc.', 'street_address' => '20341 Whitworth Institute', 'street_address_2' => '405 N. Whitworth', 'locality' => 'Seattle', 'admin_area' => 'WA', 'postal_code' => '98052', 'country_iso' => 'US', ]);
The above code will produce the following:
Jane Doe
Whitworth Institute Inc.
20341 Whitworth Institute
405 N. Whitworth
Seattle, WA 98052
NOTE: The
country_isoattribute is used to determine the address's format. The default is set to US.
Custom Country Formats
This allows you to set your own formats.
setFormats(array $countries)
Arguments:
$countries- An array of country ISO codes and corresponding formats values.
Usage:
\Torann\AddressFormat\Address::setFormats([ 'GB' => '%N%n%O%n%A%n%C%n%Z %R', 'US' => '%N%n%O%n%A%n%C, %S %Z %R', ]);
Available Attributes
| Attribute | Format Key | Common Name |
|---|---|---|
| admin_area | S | state |
| locality | C | city |
| recipient | N | person's name |
| organization | O | organization |
| dependent_locality | D | |
| postal_code | Z | zip code |
| sorting_code | X | |
| street_address | A | |
| country | R |
Change Log
v1.0.0
- First release
torann/address-format 适用场景与选型建议
torann/address-format 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.82k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2016 年 10 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「street addresses」 「localized formats」 「address format」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 torann/address-format 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 torann/address-format 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 torann/address-format 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A library that can render international postal addresses in different formats.
Laravel Package for opinionated addresses style
Country select field localized for every single language. It is intended to be used in ATK14 Forms.
PHP Interface for Babel Street Text Analytics
Localized formatting of personal names, addresses and telephone numbers.
Addresses Manager for Laravel Enso
统计信息
- 总下载量: 4.82k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2016-10-12