承接 graftak/country-code-helper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

graftak/country-code-helper

Composer 安装命令:

composer require graftak/country-code-helper

包简介

Simple package to assist you in converting/mapping ISO 3166-1 Alpha-2, Alpha-3, and Numeric Country Codes.

README 文档

README

Simple package to assist you in converting/mapping ISO 3166-1 Alpha-2, Alpha-3, and Numeric Country Codes.

Installation

Install the latest version with

$ composer require graftak/country-code-helper

Usage

Include these two classes:

use Graftak\CountryCodeHelper;
use Graftak\CountryCodeHelper\CountryCodes;

Then, in your code, just use the static method map:

CountryCodeHelper::map($value, $toType);

The first parameter $value is the country code (string) you want to map from. For example:

  • 'NL' (2-letter country code for The Netherlands)
  • 'BRA' (3-letter country code for Brazil)
  • '024' (numeric country code for Angola)

The second parameter $toType is the type you want to map to. These types are supported:

CountryCodes::ALPHA_2
CountryCodes::ALPHA_3
CountryCodes::NUMERIC
CountryCodes::SHORT_NAME_ENGLISH
CountryCodes::SHORT_NAME_FRENCH

Optionally you can supply the third parameter to explicitly define the type of the given $value (you can use any of the constants above).

Examples

<?php

use Graftak\CountryCodeHelper;
use Graftak\CountryCodeHelper\CountryCodes;

// Example 1 (The Netherlands): Two-letter to three-letter code.
print CountryCodeHelper::map('NL', CountryCodes::ALPHA_3);
// Output: 'NLD'

// Example 2 (Philippines): Numeric to two-letter code.
print CountryCodeHelper::map(608, CountryCodes::ALPHA_2);
// Output: 'PH'

// Example 3 (Virgin Islands): Two-letter to English name.
print CountryCodeHelper::map('VG', CountryCodes::SHORT_NAME_ENGLISH);
// Output: 'Virgin Islands (British)'

About

Requirements

  • PHP 5.6 or up

Country Codes - ISO 3166

What is ISO 3166? ISO 3166 is the International Standard for country codes and codes for their subdivisions.

The purpose of ISO 3166 is to define internationally recognised codes of letters and/or numbers that we can use when we refer to countries and subdivisions. However, it does not define the names of countries – this information comes from United Nations sources (Terminology Bulletin Country Names and the Country and Region Codes for Statistical Use maintained by the United Nations Statistics Divisions).

Using codes saves time and avoids errors as instead of using a country's name (which will change depending on the language being used) we can use a combination of letters and/or numbers that are understood all over the world.

For example, all national postal organizations throughout the world exchange international mail in containers identified with the relevant country code. Internet domain name systems use the codes to define top level domain names such as '.fr' for France, '.au' for Australia. In addition, in machine readable passports, the codes are used to determine the nationality of the user and when we send money from one bank to another the country codes are a way to identify where the bank is based.

Excerpt from: https://www.iso.org/iso-3166-country-codes.html

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub

Author

Bert van der Genugten

License

Country Code Helper is licensed under the BSD-3-Clause License - see the LICENSE file for details

Acknowledgements

Data source: https://www.iso.org/obp/ui/#search/code/

More information about ISO 3166 can be found on the official website of ISO (International Organization for Standardization): https://www.iso.org/iso-3166-country-codes.html

graftak/country-code-helper 适用场景与选型建议

graftak/country-code-helper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 241.74k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2017 年 07 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「code」 「convert」 「mapping」 「list」 「english」 「country」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 graftak/country-code-helper 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 241.74k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 35
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2017-07-29