tjbp/countries
Composer 安装命令:
composer require tjbp/countries
包简介
Fast and lightweight utilities for ISO 3166 country data.
README 文档
README
A PHP lib providing fast and lightweight utilities for ISO 3166 country data.
Installation
Run the following within your project directory to install as a dependency:
composer require tjbp/countries
Usage
Quick start
use Tjbp\Currencies\Iso3166; Iso3166::get('GB')->name; // "United Kingdom of Great Britain and Northern Ireland (the)"
More detailed
use Tjbp\Countries\Iso3166; // Country object is returned with four properties Iso3166::get('GB')->name; // Iso3166::get('GB')->alpha2; // GB Iso3166::get('GB')->alpha3; // GBR Iso3166::get('GB')->numeric3; // 826 // Alternatively use an object $countries = new Iso3166; $countries->get('GB')->alpha2; // GB // Or get by specific identifiers if you prefer Iso3166::getByAlpha2('GB')->alpha2; // GB Iso3166::getByAlpha3('GBR')->alpha2; // GB Iso3166::getByNumeric3(826)->alpha2; // GB // Use the Iso3166::get() method to return a Country object $country = Iso3166::get('GB'); // Country has four properties $country->name; // "United Kingdom of Great Britain and Northern Ireland (the)" $country->alpha2; // "GB" $country->alpha3; // "GBR" $country->numeric3; // 826 // Alternatively instantiate Iso3166 $iso4217 = new Iso3166; $country = $iso4217->get('GBP'); // There are also specific identifiers if you prefer $country = Iso3166::getByAlpha2('GB'); $country = Iso3166::getByAlpha3('GBP'); $country = Iso3166::getByNumeric3(827);
Additionally you can use the HasCountries trait to access the Iso3166::get() method from within an object:
use Tjbp\Currencies\HasCountries; class Example { use HasCountries; public method example() { $this->countries('GB')->name; // "United Kingdom of Great Britain and Northern Ireland (the)" } }
Building
Run bin/build if you wish to regenerate the library using the latest ISO3166 data (though the packaged source should be up-to-date).
Contributing
Changes to the Iso3166 class are made to src/templates/Iso3166.php, since src/Iso3166.php will be overwritten when new versions are built.
Notes
Take a look at https://packagist.org/packages/tjbp/currencies
tjbp/countries 适用场景与选型建议
tjbp/countries 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 215 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 11 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 tjbp/countries 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tjbp/countries 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 215
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 22
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2015-11-07